• Post Reply Bookmark Topic Watch Topic
  • New Topic

ButtonGroup in a jMenu

 
Jamie Wool
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I'm trying to setup up a group of buttons in the menu of my appliaction, but i'm not sure how you can group buttons in a menu??
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you don't really put Buttons on a JMenu. What exactly do you mean by grouping them together? Do you just want to seperate different groups of menu items with a seperator (line) or what?
 
Jamie Wool
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Basically what i want to have is a button choice on the menu, in my example the application has 2 user types say Bob & Sue. So you can choose the Bob radio button in the menu and the Sue radio button will de-select. Assumed i'd need to set-up something with button groups!
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ahh, you didn't say "radio" buttons in your first post. Now I understand.

An excerpt from the Swing Tutorial at http://java.sun.com.



It's basically just like using JRadioButton except you use JRadioButtonMenuItem instead.
 
Jamie Wool
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thing is i'm using netbeans(no choice) and still getting the error

FrontEnd/front.java [112:1] cannot resolve symbol
symbol : class ButtonGroup
location: class FrontEnd.front
ButtonGroup group = new ButtonGroup();
^
1 error
Errors compiling front.

When i attempt to force the ButtonGroup code into the application
 
Jamie Wool
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, managed to suss it, was netbeans being rubbish, had to use

javax.swing.ButtonGroup group = new javax.swing.ButtonGroup();
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!