Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Quick beginner radio button question

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Location
    Chino CA
    Posts
    5
    My Mood
    Confused
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Quick beginner radio button question

    I'm trying to set up a JFrame shopping cart example for my class. I've added radio buttons to a button group "colorButtonGroup" to denote one of three colors (blue, red, yellow), and I'm not sure as to how to add the button group to my main panel. What am I missing? How do I add the button group to my main panel?

    mainPanel.add(colorButtonGroup);

    I'm new to programming, and was hoping this would be an easy problem to resolve. I originally placed the individual radio buttons directly onto the main panel but was having trouble with the actionListener.


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Quick beginner radio button question

    You don't add the ButtonGroup to the Container. You add each button. A ButtonGroup is not an actual Component, it's just a way to link the models of the buttons together.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. The Following User Says Thank You to KevinWorkman For This Useful Post:

    smarmy_cheauffeur (October 17th, 2011)

  4. #3
    Junior Member
    Join Date
    Oct 2011
    Location
    Chino CA
    Posts
    5
    My Mood
    Confused
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Quick beginner radio button question

    Works for me (not literally), thanks

Similar Threads

  1. [SOLVED] I am unable to read radio button actions in JSP
    By abhiM in forum What's Wrong With My Code?
    Replies: 5
    Last Post: August 17th, 2011, 01:41 AM
  2. need help Coding RADIO BUTTON for REMEMBER ME
    By timosoft in forum Java Theory & Questions
    Replies: 3
    Last Post: February 4th, 2011, 05:19 PM
  3. Quick, beginner-level Java question.
    By DHG in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 27th, 2011, 01:06 PM
  4. Adding Radio Button Values
    By bazazu in forum What's Wrong With My Code?
    Replies: 6
    Last Post: November 13th, 2010, 10:41 AM
  5. Action from Radio Button
    By halfwaygone in forum What's Wrong With My Code?
    Replies: 0
    Last Post: April 25th, 2010, 10:52 AM