List of usage examples for javax.swing JTextField JTextField
public JTextField()
TextField
. From source file:Main.java
public static void main(String[] argv) throws Exception { JTextField component = new JTextField(); JLabel label = new JLabel("Name:"); label.setDisplayedMnemonic('N'); label.setLabelFor(component);/*from w ww . ja v a2s . c o m*/ }
From source file:Main.java
public static void main(String[] a) { JTextField jTextField1 = new JTextField(); jTextField1.setText("java2s.com"); jTextField1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("action"); }/*from w w w . j a v a2 s . c o m*/ }); JOptionPane.showMessageDialog(null, jTextField1); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JTextField component = new JTextField(); component.addKeyListener(new MyKeyListener()); JFrame f = new JFrame(); f.add(component);//from ww w . j a v a 2s . c o m f.setSize(300, 300); f.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JTextField component = new JTextField(); component.addFocusListener(new MyFocusListener()); JFrame f = new JFrame(); f.add(component);//from w w w.j a v a 2 s . c o m f.setSize(300, 300); f.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JTextField component = new JTextField(); component.addMouseListener(new MyMouseListener()); JFrame f = new JFrame(); f.add(component);/*from w w w .j a v a 2 s . c o m*/ f.setSize(300, 300); f.setVisible(true); component.addMouseListener(new MyMouseListener()); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JTextComponent component = new JTextField(); if (component instanceof JTextComponent) { JTextComponent textComp = (JTextComponent) component; Keymap keymap = textComp.getKeymap(); while (keymap != null) { Action[] actions = keymap.getBoundActions(); for (int i = 0; i < actions.length; i++) { Action action = actions[i]; }/*from w w w.j a v a2 s. co m*/ Action defaultAction = keymap.getDefaultAction(); keymap = keymap.getResolveParent(); } } }
From source file:Main.java
public static void main(String[] argv) throws Exception { JTextField component = new JTextField(); component.addMouseMotionListener(new MyMouseMotionListener()); JFrame f = new JFrame(); f.add(component);//from w ww . j a v a 2s. c om f.setSize(300, 300); f.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JTextComponent component = new JTextField(); // Process action list Action actions[] = component.getActions(); // Define comparator to sort actions Comparator<Action> comparator = new Comparator<Action>() { public int compare(Action a1, Action a2) { String firstName = (String) a1.getValue(Action.NAME); String secondName = (String) a2.getValue(Action.NAME); return firstName.compareTo(secondName); }/*from w ww .j av a2s.co m*/ }; Arrays.sort(actions, comparator); int count = actions.length; System.out.println("Count: " + count); for (int i = 0; i < count; i++) { System.out.printf("%28s : %s\n", actions[i].getValue(Action.NAME), actions[i].getClass().getName()); } }
From source file:Main.java
public static void main(String args[]) { JTextField textField1 = new JTextField(); JTextField textField2 = new JTextField(); InputVerifier verifier = new InputVerifier() { public boolean verify(JComponent comp) { boolean returnValue; JTextField textField = (JTextField) comp; try { Integer.parseInt(textField.getText()); returnValue = true;//ww w . j av a2 s. com } catch (NumberFormatException e) { returnValue = false; } return returnValue; } }; textField1.setInputVerifier(verifier); JFrame frame = new JFrame("Verifier Sample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(textField1, BorderLayout.NORTH); frame.add(textField2, BorderLayout.CENTER); frame.setSize(300, 100); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JTextField component = new JTextField(); component.addMouseListener(new MyMouseListener()); JFrame f = new JFrame(); f.add(component);/*w ww . ja v a2 s . c o m*/ f.setSize(300, 300); f.setVisible(true); }