This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to Use Action Objects with Events ??  RSS feed

John Cooney
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to use Action objects for events (for instance key events)? How do you register with the action object, for these events ??
Action ActionObj = new AbstractAction() {
public void actionPerformed(ActionEvent e) {
if (e.getSource() == aboutMenuItem) {
System.out.println("About menu pressed");
} else if (e.getSource() == exitMenuItem) {
System.out.println("Exit menu pressed");
public void keyReleased(KeyEvent e) {
if (e.getSource() == aTextField) {
System.out.println("KeyEvent: Seats Booking Field");
aboutMenuItem.setAction(ActionObj); // works ok
exitMenuItem.setAction(ActionObj); // works ok
aTextField. ??? // want to register for key events
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!