List of usage examples for java.awt.event FocusEvent getID
public int getID()
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); }/*ww w . j a v a 2s. co 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
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); }/*w w w. j a v a 2 s . com*/ public void focusLost(FocusEvent e) { displayMessage("Focus lost", e); } void displayMessage(String prefix, FocusEvent e) { System.out.println(e.getID() == FocusEvent.FOCUS_LOST); } }); frame.add(textField, "North"); frame.add(new JTextField(), "South"); frame.setSize(300, 200); frame.setVisible(true); }
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. ja va2s. co m public void focusLost(FocusEvent e) { displayMessage("Focus lost", e); } void displayMessage(String prefix, FocusEvent e) { System.out.println(e.getID() == FocusEvent.FOCUS_LAST); } }); frame.add(textField, "North"); frame.add(new JTextField(), "South"); frame.setSize(300, 200); frame.setVisible(true); }
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 www . j a va 2 s. com public void focusLost(FocusEvent e) { displayMessage("Focus lost", e); } void displayMessage(String prefix, FocusEvent e) { System.out.println(e.getID() == FocusEvent.FOCUS_FIRST); } }); frame.add(textField, "North"); frame.add(new JTextField(), "South"); frame.setSize(300, 200); frame.setVisible(true); }
From source file:EventTestPane.java
/** * Display keyboard focus events. Focus can be permanently gained or lost, * or temporarily transferred to or from a component. *///from w ww . ja v a 2 s . c om 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.github.fritaly.dualcommander.TabbedPane.java
@Override public void focusGained(FocusEvent e) { // Propagate the event final FocusListener[] listeners = getListeners(FocusListener.class); if (listeners != null) { final FocusEvent event = new FocusEvent(this, e.getID(), e.isTemporary(), e.getOppositeComponent()); for (FocusListener listener : listeners) { listener.focusGained(event); }/*from ww w . j a va2 s . c om*/ } }
From source file:com.github.fritaly.dualcommander.TabbedPane.java
@Override public void focusLost(FocusEvent e) { // Propagate the event final FocusListener[] listeners = getListeners(FocusListener.class); if (listeners != null) { final FocusEvent event = new FocusEvent(this, e.getID(), e.isTemporary(), e.getOppositeComponent()); for (FocusListener listener : listeners) { listener.focusLost(event);/* w w w . j av a2 s . c o m*/ } } }
From source file:com.dbschools.quickquiz.client.taker.MainWindow.java
/** * @see java.awt.event.FocusListener#focusGained(java.awt.event.FocusEvent) *//*from www . ja va2 s . c o 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:com.github.fritaly.dualcommander.DirectoryBrowser.java
@Override public void focusGained(FocusEvent e) { if (e.getSource() == table) { // Propagate the event final FocusListener[] listeners = getListeners(FocusListener.class); if (listeners != null) { final FocusEvent event = new FocusEvent(this, e.getID(), e.isTemporary(), e.getOppositeComponent()); for (FocusListener listener : listeners) { listener.focusGained(event); }/*from www.j av a 2 s . c o m*/ } } }
From source file:com.github.fritaly.dualcommander.DirectoryBrowser.java
@Override public void focusLost(FocusEvent e) { if (e.getSource() == table) { // Propagate the event final FocusListener[] listeners = getListeners(FocusListener.class); if (listeners != null) { final FocusEvent event = new FocusEvent(this, e.getID(), e.isTemporary(), e.getOppositeComponent()); for (FocusListener listener : listeners) { listener.focusLost(event); }/*from w w w .j a v a 2 s. c om*/ } } }