List of usage examples for javax.swing JLabel setLabelFor
@BeanProperty(description = "The component this is labelling.") public void setLabelFor(Component c)
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 source file:Main.java
public static void main(String[] argv) throws Exception { JTextField textfield = new JTextField(25); // Create label and associate with text field JLabel label = new JLabel("Text Label"); label.setDisplayedMnemonic(KeyEvent.VK_L); label.setLabelFor(textfield); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame("JFrame"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTextField nameTextField = new JTextField(); JLabel nameLabel = new JLabel("Name:"); nameLabel.setDisplayedMnemonic('N'); nameLabel.setLabelFor(nameTextField); frame.add(nameLabel, BorderLayout.WEST); frame.add(nameTextField, BorderLayout.CENTER); frame.pack();//from w w w . j a va 2 s . co m frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame("Label Focus Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel(new BorderLayout()); JLabel label = new JLabel("Name: "); label.setDisplayedMnemonic(KeyEvent.VK_N); JTextField textField = new JTextField(); label.setLabelFor(textField); panel.add(label, BorderLayout.WEST); panel.add(textField, BorderLayout.CENTER); frame.add(panel, BorderLayout.NORTH); frame.add(new JButton("Somewhere Else"), BorderLayout.SOUTH); frame.setSize(250, 150);/* w w w . j a v a2s. com*/ frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JTextField firstField = new JTextField(10); JTextField middleField = new JTextField(10); JTextField lastField = new JTextField(10); JLabel firstLabel = new JLabel("First Name", JLabel.RIGHT); firstLabel.setDisplayedMnemonic('F'); firstLabel.setLabelFor(firstField); JLabel middleLabel = new JLabel("Middle Initial", JLabel.RIGHT); middleLabel.setDisplayedMnemonic('I'); middleLabel.setDisplayedMnemonicIndex(7); middleLabel.setLabelFor(middleField); JLabel lastLabel = new JLabel("Last Name", JLabel.RIGHT); lastLabel.setDisplayedMnemonic('L'); lastLabel.setLabelFor(lastField);//from w ww . j av a 2 s. co m JPanel p = new JPanel(); p.setLayout(new GridLayout(3, 2, 5, 5)); p.add(firstLabel); p.add(firstField); p.add(middleLabel); p.add(middleField); p.add(lastLabel); p.add(lastField); JFrame f = new JFrame("MnemonicLabels"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setContentPane(p); f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] a) { JFrame frame = new JFrame("LabelFor Sample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label = new JLabel("Username"); JTextField textField = new JTextField(); label.setDisplayedMnemonic(KeyEvent.VK_U); label.setLabelFor(textField); Container box = Box.createHorizontalBox(); box.add(label);//from ww w. ja v a 2s .c om box.add(textField); frame.add(box, BorderLayout.NORTH); frame.add(new JButton("Submit"), BorderLayout.SOUTH); frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JPanel panel = new JPanel(new BorderLayout()); JLabel label = new JLabel("Name: "); label.setDisplayedMnemonic(KeyEvent.VK_N); JTextField textField = new JTextField(); label.setLabelFor(textField); panel.add(label, BorderLayout.WEST); panel.add(textField, BorderLayout.CENTER); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(panel, BorderLayout.NORTH); frame.add(new JButton("Somewhere Else"), BorderLayout.SOUTH); frame.setSize(250, 150);/*from www. ja v a2 s . c o m*/ frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame("Label Focus Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label = new JLabel("Name: "); label.setDisplayedMnemonic(KeyEvent.VK_N); JTextField textField = new JTextField(); label.setLabelFor(textField); frame.add(label, BorderLayout.WEST); frame.add(textField, BorderLayout.CENTER); frame.add(new JButton("Somewhere Else"), BorderLayout.SOUTH); frame.setSize(250, 100);/* ww w. ja va 2 s .c o m*/ frame.setVisible(true); }
From source file:LabelFor.java
public static void main(String args[]) { JFrame f = new JFrame("LabelFor Sample"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container content = f.getContentPane(); JLabel label = new JLabel("Username"); JTextField textField = new JTextField(); label.setDisplayedMnemonic(KeyEvent.VK_U); label.setLabelFor(textField); Container box = Box.createHorizontalBox(); box.add(label);//w ww.j a v a2 s. c om box.add(textField); content.add(box, BorderLayout.NORTH); content.add(new JButton("Submit"), BorderLayout.SOUTH); f.setSize(300, 200); f.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel(new BorderLayout()); JLabel label = new JLabel("Name: "); label.setDisplayedMnemonic(KeyEvent.VK_N); JTextField textField = new JTextField(); label.setLabelFor(textField); panel.add(label, BorderLayout.WEST); panel.add(textField, BorderLayout.CENTER); frame.add(panel, BorderLayout.NORTH); frame.add(new JButton("Somewhere Else"), BorderLayout.SOUTH); frame.setSize(250, 150);//from w w w.j a v a 2 s . c o m frame.setVisible(true); }