• Post Reply Bookmark Topic Watch Topic
  • New Topic

JButton ActionListener Behavior

 
Dennis Putnam
Ranch Hand
Posts: 377
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a problem with a JButton that I do not understand. My input pane collected some data and when the correct button is clicked, it processes the data, clears the fields and waits for another button action. The 'Quit' works just fine as it simply does a frame.dispose(). It is the 'Submit' button that is behaving strangely. It appears that it goes into an unending loop running the ActionListener. The button also displays as clicked and stays that way. Do I need to somehow reset that button in the ActionListener or should I be looking elsewhere for a unending loop? TIA.
 
Piet Souris
Rancher
Posts: 1635
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Without knowing the code in that ActionListener, my best guess is indeed some eternal loop within that code. Does your GUI freeze after pressing that button?

greetz,
Piet
 
Dennis Putnam
Ranch Hand
Posts: 377
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply. I take if from your answer that the listener is triggered only once per click (which is only logical) and no code is needed in the listener. I can now look for an external loop somewhere without worrying I'm chasing wild geese.
 
Piet Souris
Rancher
Posts: 1635
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome!

Yes, the listener is called once every click. But I wouldn't say that no code is needed in the listener... after all, you want a click to have some action involved?

Anyway, success!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!