This week's book giveaway is in the Java in General forum.
We're giving away four copies of Java by Comparison (eBook) and have Simon Harrer, Jörg Lenhard, Linus Dietz on-line!
See this thread for details.
Win a copy of Java by Comparison (eBook) this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Key Event Question.  RSS feed

 
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

When the user clicks on the middle button of there phone I want it to print something out to the screen. This may seem weird but this is just a test to see how it works. Since I am not actually sure how to monitor if that user has click that button or not. I was looking into key events but every example I seen seems to use the game canvus but I am not making a game.

So I am sure where to put my method. Right now I am just starring at a blank form and I would like to to display on this form.

private void keyPressed(int keyCode)
{
System.out.println("keyPressed " + ((char) keyCode));
}

Thanks
 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to print on the form you can create textfield on the form and call textfield.setString("some string") and then display.setCurrent(form)
or something like that
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!