Results 1 to 12 of 12
- 01-26-2011, 01:06 AM #1
Member
- Join Date
- Aug 2009
- Posts
- 60
- Rep Power
- 0
actionListener & setSelected(true)
I have 3 radio buttons added to a buttonGroup.
I created action listeners for each one of the buttons.
When I clicks on the buttons from the screen, the listeners work fine.
When I do setSelected(true) programatically on these buttons, why my listeners never get fire?
Thanks!
- 01-26-2011, 01:15 AM #2
Senior Member
- Join Date
- Apr 2010
- Location
- Philippines
- Posts
- 580
- Rep Power
- 4
instead of actionListener try to use ChangeListener
- 01-26-2011, 03:54 PM #3
Member
- Join Date
- Aug 2009
- Posts
- 60
- Rep Power
- 0
I can't use changeListner because I only want it to happen once when the button is selected.
Does anybody know if actionListener should or should not fire with setSelected(true)?
- 01-26-2011, 05:10 PM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,476
- Rep Power
- 16
No it shouldn't as far as I know.
You get a state change (because that's what it is), but not an action (because it isn't).
You can always fire the event yourself, though that would be a bit of a pain if you setSelected() alot.
- 01-26-2011, 05:56 PM #5
Senior Member
- Join Date
- Jan 2011
- Location
- Bangalore, India
- Posts
- 102
- Rep Power
- 0
Hi new2Java2009,
Can't help you with this problem, but a humble suggestion.
According to Java coding standards, your setter method should be named isSelected rather than setSelected if the argument is of boolean type.
- 01-26-2011, 06:00 PM #6
How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 01-26-2011, 06:31 PM #7
Senior Member
- Join Date
- Jan 2011
- Location
- Bangalore, India
- Posts
- 102
- Rep Power
- 0
It is not required, but recommended. Have read it in many books including SCJP by Kathy Sierra.
But i was wrong about setter methods. "is" is recommened for getter methods. These links tell the same thing
Java Beans naming convention for getter and setter methods (SCJP forum at JavaRanch)
naming methods and variables : Java Glossary
-
- 01-26-2011, 06:47 PM #9
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,405
- Blog Entries
- 7
- Rep Power
- 17
- 01-12-2012, 06:21 PM #10
Member
- Join Date
- Apr 2010
- Posts
- 13
- Rep Power
- 0
- 01-13-2012, 10:14 AM #11
Moderator
- Join Date
- Apr 2009
- Posts
- 10,476
- Rep Power
- 16
Re: actionListener & setSelected(true)
Reporting spam.
- 01-13-2012, 01:46 PM #12
Re: actionListener & setSelected(true)
How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
Similar Threads
-
while(true)
By ravian in forum New To JavaReplies: 7Last Post: 06-29-2011, 06:05 AM -
true && !true
By SirFalcon in forum New To JavaReplies: 3Last Post: 10-29-2009, 02:33 AM -
which one of the following is true about interface?
By makpandian in forum New To JavaReplies: 3Last Post: 06-30-2009, 12:23 AM -
A true newbies problem.
By Kaz in forum New To JavaReplies: 3Last Post: 06-25-2009, 06:12 AM -
setVisible(true) does not work
By Gajesh Tripathi in forum AWT / SwingReplies: 2Last Post: 10-27-2007, 07:32 PM


2Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks