1

I am trying to make a menu of a restaurant and the reason I am putting this question is because I want to have 4 panels using border layout.I am having 4 panels each of them named westPanel,topPanel,eastPanel and bottomPanel.I have already made the JRadioButtons as I want to and put them in a button group.I have made 2 of buttons groups and I want to put one button group of JRadioButtons in the west and the other on the east.Or maybe a JComboBox on the eastPanel.The problem is that when I am trying to do so by the method :

eastpanel.add(ButtonGroup(nameofgroup), BorderLayout.EAST)

says it is an error for the components of ButtonGroups.Is there any way that I can put the group in the panels or just the radio buttons?

mKorbel
  • 109,525
  • 20
  • 134
  • 319

1 Answers1

2

ButtonGroup is not a component, so it cannot be added to the panel. You need to add the individual components.

Your question is not very clear so I am not exactly sure what you are trying to achieve.

JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
buttonPanel.add(radio1);
buttonPanel.add(radio2);
eastpanel.add(buttonPanel, BorderLayout.EAST)
David Hutchison
  • 2,343
  • 2
  • 19
  • 24
  • I have 4 panels and I am trying to add all panels in a container.In those 4 panels I have in one panel 1 buttongroup of radio buttons.Thats the east.The west I want to add jcheckbox.and in the center panel add some textfields and in the bottom panel add 2 buttons.I am doing these just for practice.@camickr thank you for your answer I will go and read the API. – Bestial Wraith Jun 21 '13 at 15:04