jQuery in Action, 3rd edition
The moose likes Beginning Java and the fly likes JButton Group Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "JButton Group" Watch "JButton Group" New topic

JButton Group

Divya Kotamraju

Joined: Oct 07, 2010
Posts: 21
Hello Everyone!!

I have used an array of JRadioButtons and added them to the button group. I have used mouse Listener.

I have set the first element in the array of JRadiobuttons to true so that when I run my code the first RadioButton is selected. Now I want to display the selected JRadioButton value in a text field. So when I say buttongroup.getSelection().getActionCommand() it is not recognizing that my first RadioButton is selected .Instead if I select it again then it is displaying the value in the text field.

So my problem is how should I make the first RadioButton to be displayed in the textfield .

Can someone please help me!!

Thank you.
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3151

Can you post the code? Also which listener are you using for JRadioButtons?

Mohamed Sanaulla | My Blog
Javad Rashidi
Ranch Hand

Joined: Feb 13, 2011
Posts: 34

try this and why you dont use ActionListener instead of MouseListener?

Divya Kotamraju

Joined: Oct 07, 2010
Posts: 21
Hey Thank you guys for your response.

Javad-- I changed to ActionListener and Thank you it worked!!
I agree. Here's the link: http://aspose.com/file-tools
subject: JButton Group
It's not a secret anymore!