List of usage examples for java.awt.event FocusEvent FOCUS_GAINED
int FOCUS_GAINED
To view the source code for java.awt.event FocusEvent FOCUS_GAINED.
Click Source Link
From source file:Main.java
public static void main(String[] a) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTextField textField = new JTextField("A TextField"); textField.addFocusListener(new FocusListener() { public void focusGained(FocusEvent e) { displayMessage("Focus gained", e); }//from w w w. j a va 2 s.c o m public void focusLost(FocusEvent e) { displayMessage("Focus lost", e); } void displayMessage(String prefix, FocusEvent e) { System.out.println(e.getID() == FocusEvent.FOCUS_GAINED); } }); frame.add(textField, "North"); frame.add(new JTextField(), "South"); frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
/** * Setta il focus su form modali//from w w w. j a v a 2 s . c o m * * @param target componente che ricevera' il focus */ public static void postponeFocus(final Component target) { SwingUtilities.invokeLater(new Runnable() { public void run() { target.dispatchEvent(new FocusEvent(target, FocusEvent.FOCUS_GAINED)); } }); }
From source file:EventTestPane.java
/** * Display keyboard focus events. Focus can be permanently gained or lost, * or temporarily transferred to or from a component. *//* w w w .j a v a2 s . c o m*/ public void processFocusEvent(FocusEvent e) { if (e.getID() == FocusEvent.FOCUS_GAINED) showLine("FOCUS_GAINED" + (e.isTemporary() ? " (temporary)" : "")); else showLine("FOCUS_LOST" + (e.isTemporary() ? " (temporary)" : "")); }
From source file:com.dbschools.quickquiz.client.taker.MainWindow.java
/** * @see java.awt.event.FocusListener#focusGained(java.awt.event.FocusEvent) *///from w ww . j av a 2s . co m public final void focusGained(final FocusEvent e) { if (e.getID() == FocusEvent.FOCUS_GAINED && e.getComponent() == txtChatLine) { getRootPane().setDefaultButton(btnSendChatLine); } else if (e.getID() == FocusEvent.FOCUS_GAINED && e.getComponent() == txtAnswer) { getRootPane().setDefaultButton(btnSubmit); } }
From source file:org.xulux.swing.listeners.PrePostFieldListener.java
/** * now call pre../*ww w . ja v a 2 s . c o m*/ * @see java.awt.event.FocusListener#focusGained(FocusEvent) */ public void focusGained(FocusEvent e) { if (isProcessing()) { return; } if (e.getID() != FocusEvent.FOCUS_GAINED || e.isTemporary()) { return; } NyxEventQueue q = NyxEventQueue.getInstance(); q.holdEvents(false); started(); }