-1

I want to draw radiobuttons panel in Graphic2D but I don't know how can I do this.

@Override
    public void draw(Graphics2D g2)
    {
      // ... Here I draw some Recntangle2D objects....

    }

And here is simple jbuttonpanel with radio buttons:

 public ButtonGroup buttons() {
        JRadioButton button1 = new JRadioButton("Red");
        JRadioButton button2 = new JRadioButton("Green");
        JRadioButton button3 = new JRadioButton("Blue");
        ButtonGroup colorButtonGroup = new ButtonGroup();
        colorButtonGroup.add(button1);
        colorButtonGroup.add(button2);
        colorButtonGroup.add(button3);
        button1.setSelected(true);
        return colorButtonGroup;
    }

But I don't know how can I draw it in upper method on top where below my buttonpanel I draw some recntagles with text field.

user1803551
  • 12,965
  • 5
  • 47
  • 74
ullQuiorra
  • 31
  • 1
  • 6
  • What component do you want to draw on? What is this `draw` method you are overriding. Post an [MCVE](http://stackoverflow.com/help/mcve). – user1803551 Jan 07 '16 at 16:23

1 Answers1

2

You don't draw radio buttons. You add the radio buttons (like any other Swing component) to the panel and the panel will paint the buttons for you.

Read the section from the Swing tutorial on How to Use Radio Buttons for more information and working examples.

camickr
  • 321,443
  • 19
  • 166
  • 288