Home ยป How to capture keyboard inputs in my JWindow using Java?

How to capture keyboard inputs in my JWindow using Java?

public class Boot extends JWindow implements KeyListener
{
  public Boot()
  {
    …..
    this.addKeyListener(this);
    ….
  }

  public void keyTyped(KeyEvent ke)
  {
    System.out.println( ke.getKeyChar());
  }

  public void keyPressed(KeyEvent ke)
  {
    System.out.println( ke.getKeyChar());

    /* KEY EVENTS */
    // KeyEvent.KEY_TYPED
    // KeyEvent.KEY_PRESSED
    // int id = id.getId();

  }

  public void keyReleased(KeyEvent ke)
  {
    System.out.println( ke.getKeyChar());
  }

}

JFrame frame = new JFrame();
frame.setVisible( true );
JWindow window = new JWindow(frame);

JWindow window = new JWindow(new JFrame(“is Showing”)
{
   public boolean isShowing()
   {
     return true;
   }
});

Add Comment

Click here to post a comment

Your email address will not be published. Required fields are marked *