Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

assumptions  RSS feed

 
verduka fox
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please clarify the following for me:
I am of the understanding that actionPerformed on a JButton is fired whenever that button has an action performed on it (duh). As possible actions, I count mouse click AND hitting enter on the keyboard when the button has focus. However, hitting enter on the keyboard does not trigger actionPerformed. Is this assumption correct? If not, what do I do to assure that when enter is hit it will trigger actionPerformed?
Another understanding I have is that itemStateChanged on a JComboBox is fired when the user changes the selected item. However, from what I can see, itemStateChanged is being fired when the first selected item is DESELECTED AND when the newly selected item is SELECTED. I thought that itemStateChanged should only fire when the entire action described in the previous sentence is COMPLETED. What is the proper definition of itemStateChanged?
Thank you for your insight and clarification!
 
Suneel Setlur
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
The JButton(action event) is fired when
1. Mouse button is clicked (as you said)
2. When Enter(Return) is pressed while typing in a Text
field.
The JComboBox fires (item event) when
1. an item has been selected or deselected. The code written
for this method performs the operations that need to
occur when an item is selected (or deselected).

Regards
Suneel


[This message has been edited by Suneel Setlur (edited August 23, 2001).]
 
Suneel Setlur
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
And for your query...
Write a KeyEvent(KeyListener) for Enter pressed with the same action as that of action event.
Regards
Suneel
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!