Stupid button group problem


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Stupid button group problem

  1. #1
    Join Date
    Jan 2005
    Posts
    61

    Stupid button group problem

    I'm trying to make a button group with two JCheckBoxes, but for some reason I'm having problems adding them to the button group:

    Code:
            ButtonGroup rye = new ButtonGroup();
            JCheckBox isRye = new JCheckBox("Yes", false);
            rye.add(isRye);
            JCheckBox notRye = new JCheckBox("No", true);
            rye.add(notRye);
    Thanks for any help - this is doing my head in

  2. #2
    Join Date
    Mar 2004
    Posts
    635
    What problems are you having exactly? The code looks correct, though I don't know why you need a button group with checkboxes, because that would allow you to select both options simultaneously. Maybe you meant to use radio buttons?

  3. #3
    Join Date
    Jan 2005
    Posts
    61
    Ah, I thought I could have checkboxes where you can only select one as well. But I still get the same problem with JRadioButtons - the editor (Eclipse) is picking up this line:

    b1.add(isRye);

    It says that a variable declarator is needed after this token. Strange...

  4. #4
    Join Date
    Jan 2005
    Posts
    61
    Oops - I did say it was a stupid problem didn't I? I was trying to add the radio buttons before I had created them <slap>

    Thanks for the help anyway.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center