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






KeyEvent.VK_N

 

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

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

public class Main {
  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);
    frame.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_RIGHT
10.KeyEvent.VK_U
11.KeyEvent.VK_UP
12.KeyEvent: getKeyChar()
13.KeyEvent: getKeyCode()
14.KeyEvent: getKeyLocation()
15.KeyEvent: getKeyText(int keyCode)
16.KeyEvent: isActionKey()