Adding a panel to a panel
The following code produces the error:
"java:28: cannot find symbol
symbol : method add(javax.swing.ButtonGroup,java.lang.String)
location: class PizzaTab
add (size, BorderLayout.NORTH);
^
1 error
Tool completed with exit code 1"
Can someone point me in the right direction? Is this just a syntax prob or can I not add a buttongroup to a BorderLayout Panel?
Code:
import javax.swing.*;
public class OrderForm
{
public static void main (String[] args)
{
JFrame frame = new JFrame ("Pizza Order Form");
frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
JTabbedPane tp = new JTabbedPane();
tp.addTab ("Pizza", new PizzaTab());
frame.getContentPane().add(tp);
frame.pack();
frame.setVisible(true);
}
}
and my tab:
Code:
import java.awt.*;
import javax.swing.*;
public class PizzaTab extends JPanel
{
public PizzaTab()
{
setLayout (new BorderLayout());
setBackground (Color.cyan);
ButtonGroup size = new ButtonGroup();
JRadioButton b1 = new JRadioButton("small");
JRadioButton b2 = new JRadioButton("medium");
JRadioButton b3 = new JRadioButton("large");
size.add (b1);
size.add (b2);
size.add (b3);
add (size, BorderLayout.NORTH);
} // End
} // End of the PizzaTab