• Post Reply Bookmark Topic Watch Topic
  • New Topic

jButton actionlistener not working?  RSS feed

 
Jenn Terry
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was suspecting I had a jButton not working, so I added a console print to test. See below. When I click the button, the console doesn't display anything. Am I using the button wrong?




I have also tried the following with the same results (or lack of).

 
Swastik Dey
Rancher
Posts: 1812
15
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe both the methods are user defined methods, right? But you need to implement actionPerformed method from ActionListener interface. Next thing you need to add this listener to the component that should respond to the event. I assume that you class already implements the ActionListener interface, and taking that into consideration your code should look somewhat like this.

 
Jenn Terry
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Next thing you need to add this listener to the component that should respond to the event.


That's what I forgot to do. Too many hours straight coding I guess.

Thanks for your help. Much appreciated.
 
Swastik Dey
Rancher
Posts: 1812
15
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are welcome.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!