JTextField: setFocusAccelerator(char aKey) : JTextField « javax.swing « Java by API






JTextField: setFocusAccelerator(char aKey)

 
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;

public class Main {
  public static void main(String[] args) {
    JLabel l;
    JTextField t;
    JButton b;
    JFrame f = new JFrame("Text Accelerator");
    
    f.add(l = new JLabel("Name:", SwingConstants.RIGHT));
    l.setDisplayedMnemonic('n');
    f.add(l = new JLabel("House/Street:", SwingConstants.RIGHT));
    l.setDisplayedMnemonic('h');
    f.add(l = new JLabel("City:", SwingConstants.RIGHT));
    l.setDisplayedMnemonic('c');
    f.add(l = new JLabel("State/County:", SwingConstants.RIGHT));
    l.setDisplayedMnemonic('s');
    f.add(l = new JLabel("Zip/Post code:", SwingConstants.RIGHT));
    l.setDisplayedMnemonic('z');
    f.add(l = new JLabel("Telephone:", SwingConstants.RIGHT));
    l.setDisplayedMnemonic('t');
    f.add(b = new JButton("Clear"));
    b.setMnemonic('l');

    f.add(t = new JTextField(35));
    t.setFocusAccelerator('n');
    f.add(t = new JTextField(35));
    t.setFocusAccelerator('h');
    f.add(t = new JTextField(35));
    t.setFocusAccelerator('c');
    f.add(t = new JTextField(35));
    t.setFocusAccelerator('s');
    f.add(t = new JTextField(35));
    t.setFocusAccelerator('z');
    f.add(t = new JTextField(35));
    t.setFocusAccelerator('t');
    f.add(b = new JButton("OK"));
    b.setMnemonic('o');

    f.pack();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setVisible(true);
  }
}

   
  








Related examples in the same category

1.JTextField.LEFT
2.JTextField.LEADING
3.JTextField.TRAILING
4.new JTextField(String text)
5.new JTextField(String text, int columns)
6.JTextField: addActionListener(ActionListener s)
7.JTextField: addFocusListener(FocusListener l)
8.JTextField: addKeyListener(KeyListener l)
9.JTextField: copy()
10.JTextField: cut()
11.JTextField: getActions()
12.JTextField: getCaretPosition()
13.JTextField: getDocument()
14.JTextField: getHorizontalVisibility()
15.JTextField: getHorizontalVisibility() (2)
16.JTextField: getInputMap()
17.JTextField: getKeymap()
18.JTextField: getScrollOffset()
19.JTextField: paste()
20.JTextField: registerKeyboardAction(ActionListener anAction,String aCommand,KeyStroke aKeyStroke,int aCondition)
21.JTextField: requestFocus()
22.JTextField: modelToView(int pos)
23.JTextField: read(Reader in, Object desc)
24.JTextField: setDocument(Document doc)
25.JTextField: setHorizontalAlignment(int alignment)
26.JTextField: setInputVerifier(InputVerifier input)
27.JTextField: setPreferredSize(Dimension preferredSize)
28.JTextField: setNavigationFilter(NavigationFilter filter)
29.JTextField: setTransferHandler(TransferHandler newHandler)
30.JTextField: write(Writer out)