DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 4 of 4
  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.

Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links