Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JButton Group  RSS feed

 
Divya Kotamraju
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 3169
34
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post the code? Also which listener are you using for JRadioButtons?
 
Javad Rashidi
Ranch Hand
Posts: 34
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try this and why you dont use ActionListener instead of MouseListener?
 
Divya Kotamraju
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Thank you guys for your response.

Javad-- I changed to ActionListener and Thank you it worked!!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!