aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How to make label visible Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to make label visible" Watch "How to make label visible" New topic
Author

How to make label visible

Jeff Ciaccio
Greenhorn

Joined: Nov 26, 2008
Posts: 25
I have created a radio button group with two buttons in NetBeans, and I would like some text to show up when the button is chosen and become greyed out when it is not chosen.

I have tried adding the code:


When I run, the buttons are no longer mutually exclusive, and the text does not go visible/invisible as I was expecting.

Any suggestions for a NetBeans newbie?

Thanks,
Jeff


Jeff Ciaccio, Java novice <br />Physics and AP Physics Teacher<br />Sprayberry High School <br />Marietta, GA
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 1973
    
    7

You need a ButtonGroup object then add those radio buttons to the group like below.



After that you need a action listener to control which radio button is enabled, eg click name button will disable location button and vice versa. To enable/disable radio button you can use the setEnable() method.


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7
Jeff Ciaccio
Greenhorn

Joined: Nov 26, 2008
Posts: 25
I've created the group, and both buttons are in it. Before I added the event hanlder, the buttons worked with mutal exclusivity. Now they do not
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 1973
    
    7

The actionPerformed method in the action listener should be public. The action listener class should be a class within your GUI class like this:

Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 9994
    
    7

Jeff,
Please read this
Moving to a more appropriate forum.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to make label visible
 
Similar Threads
How to send a mouse event to a component where cursor is?
UnChecking a single radio button
Problem with radio button
I want to submit the button but not refresh the page
Buttons...