CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 1999
    Location
    Atlanta, Georgia
    Posts
    6

    Any idea how to add a JRadioButton.?

    The following code produces this error:
    Test.java:2586: Incompatible type for method. Can't convert javax.swing.
    ButtonGroup to java.awt.Component.
    PanelGroup.add(group);
    ^
    1 error

    This is the code:
    JPanel PanelGroup = JPanel();
    ButtonGroup group = new ButtonGroup();

    group.add(oneRadio);
    group.add(twoRadio);
    group.add(threeRadio);
    group.add(fourRadio);

    Thanks for your help.


  2. #2
    Join Date
    Sep 2000
    Location
    Texas
    Posts
    22

    Re: Any idea how to add a JRadioButton.?

    as you add the buttons to the button group, it also has to be added to the JPanel since buttonGroup doesn't have anything to do w/ displaying the buttons on screen.. button group handles how the buttons interact w/ each other.


    JPanel PanelGroup = new JPanel();
    ButtonGroup group = new ButtonGroup();
    group.add(one);
    PanelGroup.add(one);
    etc..




    "There are no facts, only interpretations."
    -Friedrich Nietzsche

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured