/** 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(); }
/** 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); }
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; } }
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 } } }
/** Delegates to the original listener. */ @Override public void focusLost(FocusEvent ev) { FocusListener l = (FocusListener) super.get(ev); if (l != null) { l.focusLost(ev); } }
@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; }
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; } } }
@Override public void focusLost(FocusEvent e) { Component c = e.getOppositeComponent(); if (c != searchCombo) { removeSearchField(); } }
/******** 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); }
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); }
/** */ 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(); } } }
/** * 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(); } }); }
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(); }
@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 }
public void focusLost(FocusEvent e) { Object source = e.getSource(); if (source == windowsSwanExeTextField) { //if windowsSwanExeTextField lost focus. updateSwanExecutableFromTextField(); } }
@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(); } }
@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); } }); }
@Override public void giveFocus(ComponentOperator operator) { operator.requestFocus(); eDriver.dispatchEvent(operator.getSource(), new FocusEvent(operator.getSource(), FocusEvent.FOCUS_GAINED)); }
@Override public void processFocusEvent(FocusEvent fe) { super.processFocusEvent(fe); if (Boolean.TRUE.equals(getClientProperty("isSliding"))) { //NOI18N repaint(200); } }
@Override public void focusLost(FocusEvent e) { // must revalidate immediately if (validateTask.cancel()) { this.validateName = control.getText().trim(); run(); } }
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); }
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()); }
@Override public void focusLost(FocusEvent e) { if (this.getText().isEmpty()) { super.setText(hint); super.setForeground(Color.gray); showingHint = true; } }
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(); }
@Override public void focusLost(FocusEvent e) { if (lastFocusOwner != null) { lastFocusOwner.removeKeyListener(this); lastFocusOwner = null; } unsetSelectCursor(); }
public void focusLost(FocusEvent event) { if (event.getComponent() instanceof JTable) { JTable table = (JTable) event.getComponent(); if (table.isEditing()) { table.getCellEditor().stopCellEditing(); } } }
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); }
/** * @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()); } }
/** * Called when component loses focus */ public void focusLost(FocusEvent e) { if (focusLog.isLoggable(PlatformLogger.Level.FINE)) { focusLog.fine("{0}", e); } bHasFocus = false; }
@Override public void focusLost(FocusEvent e) { Component c = e.getOppositeComponent(); if (c != searchTextField) { removeSearchField(); } }
public DFrame(final Control control) { super(new BorderLayout()); setFocusable(true); setFocusCycleRoot(true); this.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { control.focusGained(DFrame.this); } }); control.addDFrame(this); }
@Override public void focusLost(FocusEvent e) { PointerInfo pi = MouseInfo.getPointerInfo(); Point p = pi.getLocation(); System.out.println("X is " + p.x); System.out.println("Y is " + p.y); x = p.x; y = p.y; button1.setLabel("Try Again"); label.setText("Successfully Clicked. Ready to Start Crushing..."); label.setBackground(Color.GREEN); button2.setEnabled(true); button1.removeFocusListener(focusListerner); }
@Override public void focusLost(FocusEvent e) { Object source = e.getSource(); if (source instanceof JTextField) { JTextField textField = (JTextField) source; String inputText = textField.getText(); switch(targetToken) { case JdbcUrl.TOKEN_HOST: case JdbcUrl.TOKEN_DB: case JdbcUrl.TOKEN_SID: case JdbcUrl.TOKEN_SERVICENAME: case JdbcUrl.TOKEN_TNSNAME: case JdbcUrl.TOKEN_DSN: case JdbcUrl.TOKEN_SERVERNAME: case JdbcUrl.TOKEN_INSTANCE: case USERINPUT_FIELD: textField.setText(inputText.trim()); break; case JdbcUrl.TOKEN_PORT: Integer port = null; try { port = Integer.valueOf(inputText.trim()); } catch (NumberFormatException ex) {} if(port != null) { textField.setText(Integer.toString(port)); } else { Matcher numberMatcher = numbers.matcher(inputText); if(numberMatcher.find()) { textField.setText(numberMatcher.group(1)); } else { textField.setText(""); } } break; default: // Unhandled fields are left untouched break; } } }
public void focusGained(FocusEvent e) { // some control sends this event, color the pot control border red for that control and others blank Component src=e.getComponent(); // log.info("focus gained by "+src.getClass().getSimpleName()); if (selectedControl != null)((JComponent)selectedControl).setBorder(unselectedBorder); do{ Component parent=src.getParent(); if (componentList.contains(parent)) { ((JComponent)parent).setBorder(selectedBorder); selectedControl=parent; break; } src = parent; } while(src != null); }
public void assertLost(String msg) { int currLostCount = lostCount; lostCount = 0; FocusEvent lost = lostEvent; lostEvent = null; assertNotNull (msg, lost); assertTrue("Received wrong number of focus lost events for a single click away from a focused renderer" + currLostCount, currLostCount == 1); }
@Override public void focusLost(FocusEvent fe) { confirm(fe); }
public void focusLost(FocusEvent e) { getComponent().repaint(); }
@Override public void focusLost(FocusEvent e) { /* * do nothing */ }
@Override public boolean requestFocus(Component lightweightChild, boolean temporary, boolean focusedWindowChangeAllowed, long time, FocusEvent.Cause cause) { if (WKeyboardFocusManagerPeer. processSynchronousLightweightTransfer((Component)target, lightweightChild, temporary, focusedWindowChangeAllowed, time)) { return true; } int result = WKeyboardFocusManagerPeer .shouldNativelyFocusHeavyweight((Component)target, lightweightChild, temporary, focusedWindowChangeAllowed, time, cause); switch (result) { case WKeyboardFocusManagerPeer.SNFH_FAILURE: return false; case WKeyboardFocusManagerPeer.SNFH_SUCCESS_PROCEED: if (focusLog.isLoggable(PlatformLogger.Level.FINER)) { focusLog.finer("Proceeding with request to " + lightweightChild + " in " + target); } Window parentWindow = SunToolkit.getContainingWindow((Component)target); if (parentWindow == null) { return rejectFocusRequestHelper("WARNING: Parent window is null"); } final WWindowPeer wpeer = AWTAccessor.getComponentAccessor() .getPeer(parentWindow); if (wpeer == null) { return rejectFocusRequestHelper("WARNING: Parent window's peer is null"); } boolean res = wpeer.requestWindowFocus(cause); if (focusLog.isLoggable(PlatformLogger.Level.FINER)) { focusLog.finer("Requested window focus: " + res); } // If parent window can be made focused and has been made focused(synchronously) // then we can proceed with children, otherwise we retreat. if (!(res && parentWindow.isFocused())) { return rejectFocusRequestHelper("Waiting for asynchronous processing of the request"); } return WKeyboardFocusManagerPeer.deliverFocus(lightweightChild, (Component)target, temporary, focusedWindowChangeAllowed, time, cause); case WKeyboardFocusManagerPeer.SNFH_SUCCESS_HANDLED: // Either lightweight or excessive request - all events are generated. return true; } return false; }