This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Selection of Radio button, when combo box is selected
Sophiya Behera
Greenhorn
Joined: May 10, 2012
Posts: 18
posted
0
Hi all,
I am facing a issue in dynamic selection of radio button. I want to select a radio button at runtime and it depends on the selection of combobox. I have tried the following code
radiobutton.setSelected(true) and radiobutton.getmodel().setselected(true). But nothing is working. Please help me in this.
Are you sure that combo box selection event is triggering properly?
Swastik
Sophiya Behera
Greenhorn
Joined: May 10, 2012
Posts: 18
posted
0
Hi Swastik,
Thnks for your reply.
Yes the event is triggered properly. I have debugged through each line. After setting setSelected(true) i checked for isSelected(), itis showing true. But in UI, the button is not selected. Could you please tell me any other example, if one simple button is clicked, how the radio button is selected.... That also will help me.
Swastik,
This example works. But my scenario is bit complex. I have created a panel and created group of radio buttons in that panel in a class. And i am trying to get hold of the radio button through button group. Please refer to below code. Please suggest...
It should be possible that you too. The code could have been better, but I did it in a hurry.
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
0
> After setting setSelected(true) i checked for isSelected(), itis showing true. But in UI, the button is not selected.
quite likely you have duplicate declarations of your radioButtons
1) a class field referenced by the listener
2) a local variable where you add the radioButtons to the gui,
these are the radioButtons seen on the screen, but not 'seen' by the listener
would be much easier for you to get a solution if you posted a 'simple' working example
of the problem - just a frame, comboBox, 2 radioButtons and the listener code.
Sophiya Behera
Greenhorn
Joined: May 10, 2012
Posts: 18
posted
0
Hi Swastik,
My issue is resolved. I have taken the same approach, but i was going wrong while accessing array of buttons. Everytime the values in the array was getting initialised. Thnks for your code.
Regards
Sophiya
Sophiya Behera
Greenhorn
Joined: May 10, 2012
Posts: 18
posted
0
Hi Michael,
My issue is resolved and the reson what you have specified is quite similar to my issue. Thanks for your reply.