import javax.swing.*;
import java.awt.*;
public class X {
JFrame f=new JFrame("QQ");
X(){
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container contentPane=f.getContentPane();
GroupLayout g=new GroupLayout(contentPane);
contentPane.setLayout(g);
JButton b1=new JButton("one");
JButton b2=new JButton("two");
GroupLayout.SequentialGroup sGroup=g.createSequentialGroup();
GroupLayout.ParallelGroup pGroup=g.createParallelGroup();
sGroup.addComponent(b1).addComponent(b2);
pGroup.addGroup(sGroup);
g.setHorizontalGroup(pGroup);
g.setVerticalGroup(sGroup);
f.pack();
f.setVisible(true);
}
public static void main(String[] args){
new X();
}
}
想知道为什么总是抛出异常!!请教了!