コード例 #1
0
  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);
    }
  }
コード例 #2
0
 void canvasFocusGained(FocusEvent e) {
   if (isXEmbedActive()) {
     xembedLog.fine("Forwarding FOCUS_GAINED");
     int flavor = XEMBED_FOCUS_CURRENT;
     if (e instanceof CausedFocusEvent) {
       CausedFocusEvent ce = (CausedFocusEvent) e;
       if (ce.getCause() == CausedFocusEvent.Cause.TRAVERSAL_FORWARD) {
         flavor = XEMBED_FOCUS_FIRST;
       } else if (ce.getCause() == CausedFocusEvent.Cause.TRAVERSAL_BACKWARD) {
         flavor = XEMBED_FOCUS_LAST;
       }
     }
     xembed.sendMessage(xembed.handle, XEMBED_FOCUS_IN, flavor, 0, 0);
   }
 }