表格练习
public class Biao extends Frame{
public static void main(String[] args) {
// TODO Auto-generated method stub
Frame frame=new Frame();
frame.setLayout(new GridLayout(2,1));
frame.setSize(400,300);
frame.setLocation(300, 400);
Panel panell=new Panel(new BorderLayout());
Panel panel2=new Panel(new GridLayout(2,1));
Panel panel3=new Panel(new BorderLayout());
Panel panel4=new Panel(new GridLayout(2,2));
panell.add(new Button("丽丽"),BorderLayout.EAST);
panell.add(new Button("欣欣"),BorderLayout.WEST);
panel2.add(new Button("张三"));
panel2.add(new Button("李四"));
panel3.add(new Button("米艾"),BorderLayout.EAST);
panel3.add(new Button("艾琳"),BorderLayout.WEST);
for(int i=1;i<5;i++)
{
panel4.add(new Button("第"+i+"位"));
}
panell.add(panel2,BorderLayout.CENTER);
panel3.add(panel4,BorderLayout.CENTER);
frame.add(panell);
frame.add(panel3);
frame.setVisible(true);
frame.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
}
}
结果