File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to make label visible

 
Jeff Ciaccio
Greenhorn
Posts: 25
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
K. Tsang
Bartender
Pie
Posts: 3222
12
Android Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jeff Ciaccio
Greenhorn
Posts: 25
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 3222
12
Android Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10971
11
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeff,
Please read this
Moving to a more appropriate forum.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic