Results 1 to 5 of 5
  1. #1
    nik_meback is offline Member
    Join Date
    Dec 2010
    Posts
    19
    Rep Power
    0

    Default JCheckBoxMenuItem as JRadioButtonMenuItem

    How can a ButtonGroup containing several 'JCheckBoxMenuItem's be modified so to behave as a control which allows selection of only one JCheckBoxMenuItem at a time? i.e. How to implement a group of 'JCheckBoxMenuItem's as a group of 'JRadioButtonMenuItem's?

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,874
    Rep Power
    8

    Default

    You don't. Either write the logic yourself or use a ButtonGroup of JRadioButtons.

  3. #3
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,874
    Rep Power
    8

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default

    Quote Originally Posted by KevinWorkman View Post
    You don't. Either write the logic yourself or use a ButtonGroup of JRadioButtons.
    Hmmmm.... actually, the only real difference in the two classes is the UI delegate used. All functionality is identical.

    db

  5. #5
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,874
    Rep Power
    8

    Default

    Quote Originally Posted by Darryl.Burke View Post
    Hmmmm.... actually, the only real difference in the two classes is the UI delegate used. All functionality is identical.

    db
    I stand corrected. I thought I remembered somebody saying that JCheckBoxes were not mutually exclusive when put into a ButtonGroup (which made sense because the two components "mean" different things), but that's wrong.

    Substituting JCheckBoxes for the JRadioButtons in this example works just fine.

    I have not tried with MenuItems.

    OP, can you provide an SSCCE that demonstrates the problem?

Similar Threads

  1. JMenu and JRadioButtonMenuItem
    By doron70 in forum AWT / Swing
    Replies: 3
    Last Post: 07-18-2007, 06:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •