我有一个错误在那里我的gridx和gridy从GridBoxConstraints什么也不做。我有我想要添加和更改的位置的多个对象,但是他们都不发生变化,只是停留在我留在了首位,好像我从来没有使用过grix和gridy。的gridx和Gridy不改变任何东西
public class Applet extends JApplet{
private JButton b1;
private JButton b2;
private JFrame f;
private JPanel p;
private JRadioButton r;
private JRadioButton r1;
//private JTextField demoField;
GridBagConstraints c =new GridBagConstraints();
public Applet()
{
gui();
}
public void gui()
{
f=new JFrame("Applet!");
f.setVisible(true);
f.setSize(500,500);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
p = new JPanel();
p.setVisible(true);
//demoField = new JTextField();
r = new JRadioButton("Leave a message!!");
r1 = new JRadioButton("Draw a shape!!");
b1 = new JButton("Button!");
b1.setVisible(true);
b2 = new JButton("Button 2!");
b2.setVisible(true);
r1.setVisible(true);
r.setVisible(true);
//setting grid numbers
c.gridx=0;
c.gridy = 0;
//adding to frame
p.add(b2,c);
//setting grid numbers
c.gridx = 5;
c.gridy = 2;
p.add(r1,c);
//setting grid numbers
c.gridx = 5;
c.gridy = 5;
p.add(r,c);
//setting grid numbers
c.gridx = 0;
c.gridy = 0;
p.add(b1,c);
//p.add(demoField);
f.add(p);
}