public void focusGained(FocusEvent event) {
    QuaquaUtilities.repaintBorder((JComponent) event.getComponent());

    final JTextComponent tc = (JTextComponent) event.getSource();
    if (tc.isEditable() && tc.isEnabled()) {

      String uiProperty;
      if (tc instanceof JPasswordField) {
        uiProperty = "PasswordField.autoSelect";
      } else if (tc instanceof JFormattedTextField) {
        uiProperty = "FormattedTextField.autoSelect";
      } else {
        uiProperty = "TextField.autoSelect";
      }

      if (tc.getClientProperty("Quaqua.TextComponent.autoSelect") == Boolean.TRUE
          || tc.getClientProperty("Quaqua.TextComponent.autoSelect") == null
              && UIManager.getBoolean(uiProperty)) {
        if (event instanceof CausedFocusEvent) {
          CausedFocusEvent cfEvent = (CausedFocusEvent) event;
          if (cfEvent.getCause() == Cause.TRAVERSAL_FORWARD
              || cfEvent.getCause() == Cause.TRAVERSAL_BACKWARD) {
            tc.selectAll();
          }
        }
      }
    }
    if (KeyboardFocusManager.getCurrentKeyboardFocusManager()
        instanceof QuaquaKeyboardFocusManager) {
      QuaquaKeyboardFocusManager kfm =
          (QuaquaKeyboardFocusManager) KeyboardFocusManager.getCurrentKeyboardFocusManager();
      kfm.setLastKeyboardTraversingComponent(null);
    }
  }
Exemplo n.º 2
0
 @Override
 public void focusGained(FocusEvent e) {
   if (e.getSource() instanceof JTextField) {
     JTextField tf = (JTextField) e.getSource();
     tf.selectAll();
   }
 }
 /**
  * Revalidates minimum/maximum range.
  *
  * @param event the event.
  */
 public void focusLost(FocusEvent event) {
   if (event.getSource() == this.minimumRangeValue) {
     validateMinimum();
   } else if (event.getSource() == this.maximumRangeValue) {
     validateMaximum();
   }
 }
Exemplo n.º 4
0
    public void focusLost(FocusEvent arg0) {
      if (arg0.getSource() == txtName && txtName.getText().equals(""))
        txtName.setText("<Enter your name here>");

      if (arg0.getSource() == txtPhone) validatePhone();
      if (arg0.getSource() == txtEmail) validateEmail();
    }
Exemplo n.º 5
0
    public void focusLost(FocusEvent e) {
      Object objFocus = e.getSource();
      boolean bSaveCmd = false;
      if (objFocus instanceof DataField) {
        DataField compFocus = (DataField) objFocus;
        Component comp = e.getOppositeComponent();
        if (comp instanceof JButton) {
          String strTxt = ((JButton) comp).getText();
          if (strTxt != null && strTxt.equals(WGlobal.SAVEUSER)) bSaveCmd = true;
        }

        // if the focus is not in the panel then write the file.
        /*if ((comp == null || !m_pnlDisplay.equals(comp.getParent()))
                && !bSaveCmd)
        {
            String strPrevValue = compFocus.getValue();
            String strTxt = compFocus.getText();
            if (!strPrevValue.equals(strTxt))
            {
                // save the data by writing it to the file
                AppIF appIf = Util.getAppIF();
                if (appIf instanceof VAdminIF)
                    ((VAdminIF)appIf).getUserToolBar().doSave();
                compFocus.setValue(strTxt);
            }
        }*/
      }
    }
 public void focusLost(java.awt.event.FocusEvent evt) {
   if (evt.getSource() == tf_cantidad) {
     MovimientoArticuloModificarEliminar.this.tf_cantidadFocusLost(evt);
   } else if (evt.getSource() == btn_buscar) {
     MovimientoArticuloModificarEliminar.this.btn_buscarFocusLost(evt);
   }
 }
Exemplo n.º 7
0
 // msg from JTextfield
 public void focusLost(FocusEvent e) {
   if (e.getSource() == textField) {
     textField.setBackground(GUIGlobals.theme.InactiveTextField);
     this.fireFocusLost(e.isTemporary());
     this.repaint();
   }
 }
 @Override
 public void focusGained(FocusEvent e) {
   if (!(e.getSource() instanceof JComboBox)) return;
   Object o = ((JComboBox) e.getSource()).getSelectedItem();
   if (!(o instanceof TargetSelection)) return;
   TargetSelection ts = (TargetSelection) o;
   tfAuth.setText(ts.auth);
   taDesc.setText(ts.desc);
 }
Exemplo n.º 9
0
 @Override
 public void focusGained(FocusEvent e) {
   // TODO Auto-generated method stub
   if (e.getSource() == textArea1) {
     textArea1.setBorder(border);
   } else if (e.getSource() == textArea3) {
     textArea3.setBorder(border);
   }
 }
Exemplo n.º 10
0
 public void focusLost(FocusEvent e) {
   synchronized (this) {
     if (c != null) {
       c.getDocument().removeDocumentListener(d);
       c = null;
       d = null;
     }
   }
   if (!e.isTemporary()) parent.updateField(e.getSource());
 }
Exemplo n.º 11
0
  // trim off the first charactor non-numeric input
  public void eraseNonNumeric(FocusEvent e) {
    TXLogger.logger.debug("eraseNonNumeric" + e.getComponent());
    // System.out.println("eraseNonNumeric" + e.getComponent());
    String txt = ((JTextField) (e.getComponent())).getText();

    if ((txt.charAt(txt.length() - 1) < '0' || txt.charAt(txt.length() - 1) > '9')
        && txt.charAt(txt.length() - 1) != '.') {
      txt = txt.substring(0, txt.length() - 2);
      ((JTextField) (e.getComponent())).setText(txt);
    }
  }
Exemplo n.º 12
0
 // msg from JTextfield
 public void focusGained(FocusEvent e) {
   if (e.getSource() == textField) {
     this.fireFocusGained(e.isTemporary());
   } else // if the label get's the focus then delegate it to textfield
   {
     textField.grabFocus();
     // !!! field could be not visible (scrollpane!)
     // insert mechanism to ensure visibility
   }
   textField.setBackground(GUIGlobals.theme.ActiveTextField);
 }
 @Override
 public void focusLost(FocusEvent e) {
   if (!e.isTemporary()) {
     final JTextComponent textComponent = (JTextComponent) e.getComponent();
     SwingUtilities.invokeLater(
         new Runnable() {
           public void run() {
             textComponent.select(0, 0);
           }
         });
   }
 }
 public void focusGained(FocusEvent e) {
   if (!e.isTemporary()) {
     final JTextComponent textComponent = (JTextComponent) e.getComponent();
     // using invokeLater as fix for bug 4740914
     SwingUtilities.invokeLater(
         new Runnable() {
           public void run() {
             textComponent.selectAll();
           }
         });
   }
 }
Exemplo n.º 15
0
  @Override
  public void focusGained(FocusEvent fe) {
    if (fe.getSource() == jtxt_codigo) {
      jtxt_codigo.setSelectionStart(0);

    } else if (fe.getSource() == jtxt_nombre) {
      jtxt_nombre.setSelectionStart(0);

    } else if (fe.getSource() == jtxt_cantidadCreditos) {
      jtxt_cantidadCreditos.setSelectionStart(0);
    }
  }
Exemplo n.º 16
0
        public void focusGained(FocusEvent e) {

          synchronized (this) {
            if (c != null) {
              c.getDocument().removeDocumentListener(d);
              c = null;
              d = null;
            }

            if (e.getSource() instanceof JTextComponent) {

              c = (JTextComponent) e.getSource();
              /** [ 1553552 ] Not properly detecting changes to flag as changed */
              d =
                  new DocumentListener() {

                    void fire(DocumentEvent e) {
                      if (c.isFocusOwner()) {
                        markIfModified((FieldEditor) c);
                      }
                    }

                    public void changedUpdate(DocumentEvent e) {
                      fire(e);
                    }

                    public void insertUpdate(DocumentEvent e) {
                      fire(e);
                    }

                    public void removeUpdate(DocumentEvent e) {
                      fire(e);
                    }
                  };
              c.getDocument().addDocumentListener(d);

              /** Makes the vertical scroll panel view follow the focus */
              Component cScrollPane = c.getParent().getParent();
              if (cScrollPane instanceof JScrollPane) {
                JScrollPane componentPane = (JScrollPane) cScrollPane;
                Component cPane = componentPane.getParent();
                if (cPane instanceof JPanel) {
                  JPanel panel = (JPanel) cPane;
                  Rectangle bounds = componentPane.getBounds();
                  panel.scrollRectToVisible(bounds);
                }
              }
            }
          }

          setActive((FieldEditor) e.getSource());
        }
Exemplo n.º 17
0
 void canvasFocusLost(FocusEvent e) {
   if (isXEmbedActive() && !e.isTemporary()) {
     xembedLog.fine("Forwarding FOCUS_LOST");
     int num = 0;
     if (AccessController.doPrivileged(new GetBooleanAction("sun.awt.xembed.testing"))) {
       Component opp = e.getOppositeComponent();
       try {
         num = Integer.parseInt(opp.getName());
       } catch (NumberFormatException nfe) {
       }
     }
     xembed.sendMessage(xembed.handle, XEMBED_FOCUS_OUT, num, 0, 0);
   }
 }
Exemplo n.º 18
0
 public void focusGained(FocusEvent e) {
   if (e.getSource() == Register_username) {
     if ("email address".equals(Register_username.getText())) Register_username.setText("");
   }
   if (e.getSource() == Register_password) {
     if ("password".equals(Register_password.getText())) Register_password.setText("");
     Register_password.setEchoChar('*');
   }
   if (("".equals(Register_password.getText()))
       | ("password".equals(Register_password.getText()))) {
   } else {
     Register_password.setEchoChar('*');
   }
 }
Exemplo n.º 19
0
 @Override
 public void focusLost(FocusEvent e) {
   if (e.getSource() instanceof JTextComponent) {
     JTextComponent tc = (JTextComponent) e.getSource();
     switch (tc.getName()) {
       case CN_TITLE:
         scene.setTitle(tc.getText());
         break;
       case CN_TEXT:
         scene.setSummary(tc.getText());
         break;
     }
     mainFrame.getBookController().updateScene(scene);
   }
 }
Exemplo n.º 20
0
 /** Handles information pane updates when component focus changes. */
 @Override
 public void focusGained(FocusEvent e) {
   Object src = e.getSource();
   String text = infoTable.get(src);
   infoPane.setText("<html>" + text);
   infoPane.setCaretPosition(0);
 }
Exemplo n.º 21
0
 @Override
 public void focusLost(final FocusEvent e) {
   if (!e.isTemporary() || e.getOppositeComponent() == null) {
     /*
      * we check for temporary , because a rightclick menu will cause focus lost but editing should not stop
      *
      * we also check for oppositeComponent to stopEditing when we click outside the window
      */
     ExtTextColumn.this.noset = true;
     try {
       ExtTextColumn.this.stopCellEditing();
     } finally {
       ExtTextColumn.this.noset = false;
     }
   }
 }
  private void berechneArtikelpreis(FocusEvent e) throws Throwable {
    boolean bEventBehandelt = false;

    // Source ist wnfFixpreis oder wnfRabattsatz
    if (e.getSource() == wnfFixpreis) {
      preisSetzen();
      bEventBehandelt = true;
    }

    if (!bEventBehandelt) {
      if (e.getSource() == wnfRabattsatz) {
        preisSetzen();
        bEventBehandelt = true;
      }
    }
  }
Exemplo n.º 23
0
    @Override
    public void focusLost(FocusEvent e) {
      if (e.getSource() == diaAddRirView.this.getM_tDateRir()
          && !diaAddRirView.this.getM_bAnnuler().isSelected()) {
        // lost focus sur la date, vérification de l'intégrité de la date
        String stringDate = diaAddRirView.this.getM_tDateRir().getText();
        String[] splitDate = stringDate.trim().split("/");
        if (splitDate != null && splitDate.length == 3) {
          try {
            Calendar c = Calendar.getInstance();
            c.setLenient(false);
            int year = Integer.valueOf(splitDate[2]);
            int month = Integer.valueOf(splitDate[1]) - 1;
            int day = Integer.valueOf(splitDate[0]);
            c.set(year, month, day);
            c.getTime();
          } catch (IllegalArgumentException ee) {
            JOptionPane.showMessageDialog(null, "Date du rir incorrecte (1)");
            diaAddRirView.this.getM_tDateRir().setText("");
          }

        } else {
          JOptionPane.showMessageDialog(null, "Date du rir incorrecte (2)");
          diaAddRirView.this.getM_tDateRir().setText("");
        }
      }
    }
Exemplo n.º 24
0
 public void focusGained(FocusEvent evt) {
   Component focusedComponent = evt.getComponent();
   Component parent = focusedComponent.getParent();
   if (parent instanceof JPanel) {
     ((JPanel) parent).scrollRectToVisible(focusedComponent.getBounds(null));
   }
 }
Exemplo n.º 25
0
 public void focusLost(FocusEvent event) {
   if ((curparam != null) && (event.getSource() == defval)) {
     guipanel.setDefaultValue(curparam, defval.getText());
     ((ComponentPanelInterface) comppanels.get(params.get(curparam)))
         .notifyDefaultValue(defval.getText());
   }
 }
Exemplo n.º 26
0
 public void focusGained(FocusEvent e) {
   for (int i = 0; i < textfield.length; i++) {
     if (e.getSource() == textfield[i]) {
       textfield[i].setText("");
     }
   }
 }
  public void focusLost(final FocusEvent e) {
    if (myPanel.getProject().isDisposed()) {
      myPanel.setContextComponent(null);
      myPanel.hideHint();
      return;
    }
    final DialogWrapper dialog = DialogWrapper.findInstance(e.getOppositeComponent());
    shouldFocusEditor = dialog != null;
    if (dialog != null) {
      Disposer.register(
          dialog.getDisposable(),
          new Disposable() {
            @Override
            public void dispose() {
              if (dialog.getExitCode() == DialogWrapper.CANCEL_EXIT_CODE) {
                shouldFocusEditor = false;
              }
            }
          });
    }

    // required invokeLater since in current call sequence KeyboardFocusManager is not initialized
    // yet
    // but future focused component
    //noinspection SSBasedInspection
    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {
            processFocusLost(e);
          }
        });
  }
Exemplo n.º 28
0
  public void focusGained(FocusEvent e) {
    JFormattedTextField field = (JFormattedTextField) e.getComponent();

    // Save the current field value in case the user botches up the edit.
    // This allows us to restore the prior value upon field exit
    saveFocusString = field.getText();
  } // focusGained
  @Override
  public void focusLost(FocusEvent e) {
    if (e.getSource() instanceof JFormattedTextField) {
      JFormattedTextField formattedTextField = (JFormattedTextField) e.getSource();

      if (formattedTextField == jftDateRef) {
        focusLostDate();
      }
    } else if (e.getSource() instanceof JTextField) {
      JTextField textField = (JTextField) e.getSource();

      if (textField == jtfYear) {
        focusLostYear();
      }
    }
  }
 @Override
 public void focusLost(FocusEvent e) {
   super.focusLost(e);
   AbstractButton b = (AbstractButton) e.getSource();
   b.getModel().setArmed(false);
   b.repaint();
 }