java类java.awt.event.FocusEvent的实例源码

EditorUI.java 文件源码 项目:incubator-netbeans 阅读 32 收藏 0 点赞 0 评论 0
/** Construct extended UI for the use with a text component */
public EditorUI() {
    focusL = new FocusAdapter() {
                 public @Override void focusGained(FocusEvent evt) {
                     /* Fix of #25475 - copyAction's enabled flag
                      * must be updated on focus change
                      */
                     stateChanged(null);
                     if (component!=null){
                        BaseTextUI ui = (BaseTextUI)component.getUI();
                        if (ui!=null) ui.refresh();
                     }
                 }

                 @Override
                 public void focusLost(FocusEvent e) {
                     // see #222935, update actions before menu activates
                     if (e.isTemporary()) {
                         doStateChange(true);
                     }
                 }
             };

    getToolTipSupport();
}
SpecialkeyPanel.java 文件源码 项目:incubator-netbeans 阅读 46 收藏 0 点赞 0 评论 0
/** Creates new form SpecialkeyPanel */
public SpecialkeyPanel(final Popupable parent, JTextField target) {
    this.parent = parent;
    this.target = target;
    initComponents();

    target.addFocusListener(new FocusAdapter() {

        @Override
        public void focusLost(FocusEvent e) {
            parent.hidePopup();
        }
    });

    downButton.addActionListener(this);
    enterButton.addActionListener(this);
    escButton.addActionListener(this);
    leftButton.addActionListener(this);
    rightButton.addActionListener(this);
    tabButton.addActionListener(this);
    upButton.addActionListener(this);
    wheelUpButton.addActionListener(this);
    wheelDownButton.addActionListener(this);
}
XComponentPeer.java 文件源码 项目:openjdk-jdk10 阅读 32 收藏 0 点赞 0 评论 0
void handleJavaMouseEvent(MouseEvent e) {
        switch (e.getID()) {
          case MouseEvent.MOUSE_PRESSED:
              if (target == e.getSource() &&
                  !target.isFocusOwner() &&
                  XKeyboardFocusManagerPeer.shouldFocusOnClick(target))
              {
                  XWindowPeer parentXWindow = getParentTopLevel();
                  Window parentWindow = ((Window)parentXWindow.getTarget());
                  // Simple windows are non-focusable in X terms but focusable in Java terms.
                  // As X-non-focusable they don't receive any focus events - we should generate them
                  // by ourselfves.
//                   if (parentXWindow.isFocusableWindow() /*&& parentXWindow.isSimpleWindow()*/ &&
//                       !(getCurrentNativeFocusedWindow() == parentWindow))
//                   {
//                       setCurrentNativeFocusedWindow(parentWindow);
//                       WindowEvent wfg = new WindowEvent(parentWindow, WindowEvent.WINDOW_GAINED_FOCUS);
//                       parentWindow.dispatchEvent(wfg);
//                   }
                  XKeyboardFocusManagerPeer.requestFocusFor(target, FocusEvent.Cause.MOUSE_EVENT);
              }
              break;
        }
    }
BaseCaret.java 文件源码 项目:incubator-netbeans 阅读 33 收藏 0 点赞 0 评论 0
public @Override void focusGained(FocusEvent evt) {
    if (LOG.isLoggable(Level.FINE)) {
        LOG.fine(
                "BaseCaret.focusGained(); doc=" + // NOI18N
                component.getDocument().getProperty(Document.TitleProperty) + '\n'
        );
    }

    JTextComponent c = component;
    if (c != null) {
        updateType();
        if (component.isEnabled()) {
            if (component.isEditable()) {
                setVisible(true);
        }
            setSelectionVisible(true);
        }
        if (LOG.isLoggable(Level.FINER)) {
            LOG.finer("Caret visibility: " + isVisible() + '\n'); // NOI18N
        }
    } else {
        if (LOG.isLoggable(Level.FINER)) {
            LOG.finer("Text component is null, caret will not be visible" + '\n'); // NOI18N
        }
    }
}
WeakListenerImpl.java 文件源码 项目:incubator-netbeans 阅读 38 收藏 0 点赞 0 评论 0
/** Delegates to the original listener.
*/
@Override public void focusLost(FocusEvent ev) {
    FocusListener l = (FocusListener) super.get(ev);

    if (l != null) {
        l.focusLost(ev);
    }
}
TreeView.java 文件源码 项目:incubator-netbeans 阅读 34 收藏 0 点赞 0 评论 0
@Override
public Object run() {
    switch (type) {
    case 0:
        guardedPaint((Graphics) p1);
        break;
    case 1:
        guardedValidateTree();
        break;
    case 2:
        guardedDoLayout();
        break;
    case 3:
        ExplorerTree.super.processFocusEvent((FocusEvent)p1);
        //Since the selected when focused is different, we need to force a
        //repaint of the entire selection, but let's do it in guarded more
        //as any other repaint
        repaintSelection();
        break;
    default:
        throw new IllegalStateException("type: " + type);
    }

    return null;
}
DefaultKeyboardFocusManager.java 文件源码 项目:openjdk-jdk10 阅读 34 收藏 0 点赞 0 评论 0
private boolean doRestoreFocus(Component toFocus, Component vetoedComponent,
                               boolean clearOnFailure)
{
    if (toFocus != vetoedComponent && toFocus.isShowing() && toFocus.canBeFocusOwner() &&
        toFocus.requestFocus(false, FocusEvent.Cause.ROLLBACK))
    {
        return true;
    } else {
        Component nextFocus = toFocus.getNextFocusCandidate();
        if (nextFocus != null && nextFocus != vetoedComponent &&
            nextFocus.requestFocusInWindow(FocusEvent.Cause.ROLLBACK))
        {
            return true;
        } else if (clearOnFailure) {
            clearGlobalFocusOwnerPriv();
            return true;
        } else {
            return false;
        }
    }
}
ETable.java 文件源码 项目:incubator-netbeans 阅读 32 收藏 0 点赞 0 评论 0
@Override
public void focusLost(FocusEvent e) {
    Component c = e.getOppositeComponent();
    if (c != searchCombo) {
        removeSearchField();
    }
}
DirectoryChooserUI.java 文件源码 项目:incubator-netbeans 阅读 32 收藏 0 点赞 0 评论 0
/******** implementation of focus listener, for slow click rename cancelling ******/ 

        @Override
        public void focusGained(FocusEvent e) {
            // don't allow to invoke click to rename immediatelly after focus gain
            // what may happen is that tree gains focus by mouse
            // click on selected item - on some platforms selected item
            // is not visible without focus and click to rename will
            // be unwanted and surprising for users

            // see run method
            SwingUtilities.invokeLater(this);
        }
Util.java 文件源码 项目:openjdk-jdk10 阅读 37 收藏 0 点赞 0 评论 0
private static boolean trackEvent(int eventID, Component comp, Runnable action, int time, boolean printEvent) {
    EventListener listener = null;

    switch (eventID) {
    case WindowEvent.WINDOW_GAINED_FOCUS:
        listener = wgfListener;
        break;
    case FocusEvent.FOCUS_GAINED:
        listener = fgListener;
        break;
    case ActionEvent.ACTION_PERFORMED:
        listener = apListener;
        break;
    }

    listener.listen(comp, printEvent);
    action.run();
    return Util.waitForCondition(listener.getNotifier(), time);
}
SimpleTestStepLocation.java 文件源码 项目:incubator-netbeans 阅读 37 收藏 0 点赞 0 评论 0
/**
 */
private void tfClassToTestFocusLost(FocusEvent e) {
    final Component allowFocusGain = focusGainAllowedFor;
    focusGainAllowedFor = null;

    if (multipleSourceRoots
            && interactionRestrictionsActive
            && !interactionRestrictionsSuspended) {

        final Component opposite = e.getOppositeComponent();

        if ((allowFocusGain != null) && (opposite == allowFocusGain)) {
            return;
        }
        if (opposite == btnBrowse) {
            return;
        }
        if ((opposite instanceof JLabel)
                && (((JLabel) opposite).getLabelFor() == tfClassToTest)) {
            /*
             * When a JLabel's mnemonic key is pressed, the JLabel gains focus
             * until the key is released again. That's why we must ignore such
             * focus transfers.
             */
            return;
        }

        if (!maybeDisplaySourceGroupChooser()) {

            /* send the request back to the Test to Class textfield: */
            tfClassToTest.requestFocus();
        }
    }
}
PopUp.java 文件源码 项目:hearthstone 阅读 33 收藏 0 点赞 0 评论 0
/**
 * Configurar os componentes da janela
 */
public final void init() {
    setLayout(new AbsoluteLayout());
    setUndecorated(true);
    setBackground(new Color(0, 0, 0, 0));
    add(new JLabel(imagem), new AbsoluteConstraints(0, 0));
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
            dispose();
        }
    });
}
CCCreateAnswerPlaceholderPanel.java 文件源码 项目:educational-plugin 阅读 33 收藏 0 点赞 0 评论 0
public CCCreateAnswerPlaceholderPanel(@Nullable String placeholderText, @NotNull List<String> hints) {
  if (hints.isEmpty()) {
    myHints.add(HINT_PLACEHOLDER);
  }
  else {
    myHints.addAll(hints);
  }

  myPlaceholderTextArea.setBorder(BorderFactory.createLineBorder(JBColor.border()));
  myPlaceholderTextArea.setText(placeholderText);
  myPlaceholderTextArea.addFocusListener(new FocusAdapter() {
    @Override
    public void focusGained(FocusEvent e) {
      myPlaceholderTextArea.selectAll();
    }
  });
  myPlaceholderTextArea.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, null);
  myPlaceholderTextArea.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, null);

  myHintsPanel.setBorder(BorderFactory.createLineBorder(JBColor.border()));
  ((GridLayoutManager)myHintsPanel.getLayout()).setHGap(1);

  myHintTextArea.setFont(UIUtil.getLabelFont());
  myPlaceholderTextArea.setFont(UIUtil.getLabelFont());
  myHintTextArea.addFocusListener(createFocusListenerToSetDefaultHintText());

  actionsPanel.add(createHintToolbarComponent(), BorderLayout.WEST);
  showHint();
}
FileNameController.java 文件源码 项目:incubator-netbeans 阅读 32 收藏 0 点赞 0 评论 0
@Override
public void focusGained(FocusEvent e) {

    /*
     * Order of method calls hideInfo() and super.focusGained(e) is
     * important! See bug #113202.
     */

    if (infoDisplayed) {
        hideInfo();
    }
    super.focusGained(e);   //selects all text
}
CaseExtractorGUI.java 文件源码 项目:OpenDA 阅读 28 收藏 0 点赞 0 评论 0
public void focusLost(FocusEvent e) {
       Object source = e.getSource();
       if (source == windowsSwanExeTextField) {
        //if windowsSwanExeTextField lost focus.
        updateSwanExecutableFromTextField();
       }
}
ChartEditorJPanel.java 文件源码 项目:AgentWorkbench 阅读 33 收藏 0 点赞 0 评论 0
@Override
public void focusLost(FocusEvent fe) {
    // --- Recalculate image size when leaving one of the text fields
    if(fe.getSource()==tfImageWidth){
        this.recalculateImageHeight();
    } else if(fe.getSource()==tfImageHeight) {
        this.recalculateImageWidth();
    }
}
UIUtils.java 文件源码 项目:incubator-netbeans 阅读 41 收藏 0 点赞 0 评论 0
@SuppressWarnings("OverridableMethodCallInConstructor")
DummyDatePickerComponent () {
    super(13);
    addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
            Date newValue = getDate();
            if(! Objects.equals(oldValue, newValue)) {
                support.fireChange();
            }
            setDate(newValue);
        }
    });
}
APIFocusDriver.java 文件源码 项目:openjdk-jdk10 阅读 38 收藏 0 点赞 0 评论 0
@Override
public void giveFocus(ComponentOperator operator) {
    operator.requestFocus();
    eDriver.dispatchEvent(operator.getSource(),
            new FocusEvent(operator.getSource(),
                    FocusEvent.FOCUS_GAINED));
}
IOWindow.java 文件源码 项目:incubator-netbeans 阅读 29 收藏 0 点赞 0 评论 0
@Override
public void processFocusEvent(FocusEvent fe) {
    super.processFocusEvent(fe);
    if (Boolean.TRUE.equals(getClientProperty("isSliding"))) { //NOI18N
        repaint(200);
    }
}
NameChangeSupport.java 文件源码 项目:incubator-netbeans 阅读 33 收藏 0 点赞 0 评论 0
@Override
public void focusLost(FocusEvent e) {
    // must revalidate immediately
    if (validateTask.cancel()) {
        this.validateName = control.getText().trim();
        run();
    }
}
ContainerFocusAutoTransferTest.java 文件源码 项目:openjdk-jdk10 阅读 34 收藏 0 点赞 0 评论 0
public void init() {
    robot = Util.createRobot();
    kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
    Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
        public void eventDispatched(AWTEvent event) {
            System.out.println("--> " + event);
        }
    }, FocusEvent.FOCUS_EVENT_MASK | WindowEvent.WINDOW_FOCUS_EVENT_MASK);
}
XKeyboardFocusManagerPeer.java 文件源码 项目:openjdk-jdk10 阅读 34 收藏 0 点赞 0 评论 0
public static boolean deliverFocus(Component lightweightChild,
                                   Component target,
                                   boolean temporary,
                                   boolean focusedWindowChangeAllowed,
                                   long time,
                                   FocusEvent.Cause cause)
{
    return KeyboardFocusManagerPeerImpl.deliverFocus(lightweightChild,
                                                     target,
                                                     temporary,
                                                     focusedWindowChangeAllowed,
                                                     time,
                                                     cause,
                                                     getInstance().getCurrentFocusOwner());
}
HintTextField.java 文件源码 项目:SE2017-Team2 阅读 31 收藏 0 点赞 0 评论 0
@Override
public void focusLost(FocusEvent e) {
    if (this.getText().isEmpty()) {
        super.setText(hint);
        super.setForeground(Color.gray);
        showingHint = true;
    }
}
IndependenceSwingTest.java 文件源码 项目:openjdk-jdk10 阅读 38 收藏 0 点赞 0 评论 0
public IndependenceSwingTest() {

        frame = new JFrame();
        frame.setSize(200, 200);

        // This textfield will be used to update the contents of clipboards
        tf1 = new JTextField();
        tf1.addFocusListener(new FocusAdapter() {
            public void focusGained(FocusEvent fe) {
                tf1.setText("Clipboards_Independance_Testing");
            }
        });

        // TextFields to get the contents of clipboard
        tf2 = new JTextField();
        tf3 = new JTextField();

        panel = new JPanel();
        panel.setLayout(new BorderLayout());

        panel.add(tf2, BorderLayout.NORTH);
        panel.add(tf3, BorderLayout.SOUTH);

        frame.add(tf1, BorderLayout.NORTH);
        frame.add(panel, BorderLayout.CENTER);

        frame.setVisible(true);
        tf1.requestFocus();
    }
WatchAnnotationProvider.java 文件源码 项目:incubator-netbeans 阅读 31 收藏 0 点赞 0 评论 0
@Override
public void focusLost(FocusEvent e) {
    if (lastFocusOwner != null) {
        lastFocusOwner.removeKeyListener(this);
        lastFocusOwner = null;
    }
    unsetSelectCursor();
}
PropertySheet.java 文件源码 项目:VASSAL-src 阅读 33 收藏 0 点赞 0 评论 0
public void focusLost(FocusEvent event) {
  if (event.getComponent() instanceof JTable) {
    JTable table = (JTable) event.getComponent();
    if (table.isEditing()) {
      table.getCellEditor().stopCellEditing();
    }
  }
}
Query.java 文件源码 项目:OpenDA 阅读 33 收藏 0 点赞 0 评论 0
public void focusLost(FocusEvent e) {
    // NOTE: Java's lame AWT has no reliable way
    // to take action on window closing, so this focus lost
    // notification is the only reliable way we have of reacting
    // to a closing window.  If the previous
    // notification was an erroneous one and the value has not
    // changed, then no further notification occurs.
    // This could be a problem for some users of this class.
    _notifyListeners(_name);
}
PropertyInteractionWindow.java 文件源码 项目:routerapp 阅读 35 收藏 0 点赞 0 评论 0
/**
 * @see java.awt.event.FocusListener#focusGained(java.awt.event.FocusEvent)
 */
public void focusGained(FocusEvent e) {
    if (e.getSource() == editableField) {
        String text = editableField.getText();

        editableField.setSelectionStart(0);
        editableField.setSelectionEnd(text.length());
    }
}
ContainerFocusAutoTransferTest.java 文件源码 项目:jdk8u-jdk 阅读 30 收藏 0 点赞 0 评论 0
public void init() {
    robot = Util.createRobot();
    kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
    Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
        public void eventDispatched(AWTEvent event) {
            System.out.println("--> " + event);
        }
    }, FocusEvent.FOCUS_EVENT_MASK | WindowEvent.WINDOW_FOCUS_EVENT_MASK);
}
XComponentPeer.java 文件源码 项目:openjdk-jdk10 阅读 37 收藏 0 点赞 0 评论 0
/**
 * Called when component loses focus
 */
public void focusLost(FocusEvent e) {
    if (focusLog.isLoggable(PlatformLogger.Level.FINE)) {
        focusLog.fine("{0}", e);
    }
    bHasFocus = false;
}


问题


面经


文章

微信
公众号

扫码关注公众号