Win a copy of Kotlin in Action this week in the Kotlin 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
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!