KeyEvent.VK_U : KeyEvent « java.awt.event « Java by API






KeyEvent.VK_U

 
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.event.KeyEvent;

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

public class Main {
  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);
    box.add(textField);
    content.add(box, BorderLayout.NORTH);
    content.add(new JButton("Submit"), BorderLayout.SOUTH);
    f.setSize(300, 200);
    f.setVisible(true);
  }
}

   
  








Related examples in the same category

1.KeyEvent.KEY_LOCATION_LEFT
2.KeyEvent.KEY_LOCATION_NUMPAD
3.KeyEvent.KEY_LOCATION_RIGHT
4.KeyEvent.KEY_LOCATION_STANDARD
5.KeyEvent.KEY_TYPED
6.KeyEvent.VK_B
7.KeyEvent.VK_DOWN
8.KeyEvent.VK_LEFT
9.KeyEvent.VK_N
10.KeyEvent.VK_RIGHT
11.KeyEvent.VK_UP
12.KeyEvent: getKeyChar()
13.KeyEvent: getKeyCode()
14.KeyEvent: getKeyLocation()
15.KeyEvent: getKeyText(int keyCode)
16.KeyEvent: isActionKey()