File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "JButton Group" Watch "JButton Group" New topic
Author

JButton Group

Divya Kotamraju
Greenhorn

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: 3054
    
  33

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?


http://www.myviwo.com
Divya Kotamraju
Greenhorn

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
 
Similar Threads
Array question
Comparing value of radio button against answer from the database
listSelectionListener help needed
A diffrent type of checkbox problem
lost focus