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

Radio Button Selection Problem  RSS feed

 
Jan Tang
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all
I am pretty new to java. I set up a ButtonGroup which contains 3 RadioButtons. When I pressed "Load" button the form will retrieve the data from a database and display the relevant information of the specific record.Then I made a new button called "new record" to clear all the information 'DISPLAYED' on the form. The actionPerformed of "new record" button is:


all the information within the textfields was cleared since I pressed the button, however, the selected RadioButton is still selected which I thought there should be no radiobutton selected after pressing the button.

Can anyone help me out here? Really appreciate!

cheers
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in a buttonGroup, once a selection has been made, one must always be selected

workarounds
1) add a dummy button to the group, but do not display it.
instead of setting the current selection to false, you set the dummy to be selected
2) remove the selected button from the button group, set its selection to false,
then re-add it to the button group
 
Jan Tang
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Michael Dunn:
in a buttonGroup, once a selection has been made, one must always be selected

workarounds
1) add a dummy button to the group, but do not display it.
instead of setting the current selection to false, you set the dummy to be selected
2) remove the selected button from the button group, set its selection to false,
then re-add it to the button group


OK,now I get it. I've tried to make a dummy button before but I just thought there could be some better ways to solve this problem. It seems that I'd better add that button again now.Thanks for your help buddy.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!