Java KeyEvent VK_F11

Syntax

KeyEvent.VK_F11 has the following syntax.

public static final int VK_F11

Example

In the following code shows how to use KeyEvent.VK_F11 field.


//ww  w  .java 2  s.  c o  m
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class Main extends JPanel implements KeyListener {
  public Main() {
    addKeyListener(this);
  }

  public void keyPressed(KeyEvent evt) {
    int keyCode = evt.getKeyCode();

    if (keyCode == KeyEvent.VK_F11){
      System.out.println("KeyEvent.VK_F11");
    }
  }

  public void keyReleased(KeyEvent evt) {
  }

  public void keyTyped(KeyEvent evt) {
  }

  public boolean isFocusTraversable() {
    return true;
  }

  public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setSize(300, 200);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.add(new Main());

    frame.setVisible(true);
  }
}




















Home »
  Java Tutorial »
    java.awt.event »




AdjustmentListener
ActionEvent
ActionListener
HierarchyEvent
HierarchyListener
InputEvent
ItemEvent
ItemListener
KeyAdapter
KeyEvent
KeyListener
MouseAdapter
MouseEvent
MouseListener
MouseMotionAdapter
MouseMotionListener
MouseWheelEvent
MouseWheelListener
WindowAdapter
WindowEvent
WindowFocusListener
WindowStateListener