import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class star2 extends JApplet// implements ActionListener
{
public void init()
{
Container cp=getContentPane();
JButton jb[]=new JButton[15];
Box box=Box.createVerticalBox();
JPanel pal=new JPanel();
Box box2=Box.createVerticalBox();
JTextField jtf=new JTextField(10);
pal.setLayout(new BorderLayout(5,5)); //因为 Box 只能使用 BoxLayout,使用setLayout()会抛AWTError
GridLayout layout=new GridLayout(3,3,5,5);
JButton jbb1=new JButton("+");
JButton jbb2=new JButton("-");
JButton jbb3=new JButton("*");
JButton jbb4=new JButton("/");
JButton jbb5=new JButton("=");
box.add(jtf);
pal.add("NORTH",jbb1);
pal.add("SOUTH",jbb2);
pal.add("WEST",jbb3);
pal.add("EAST",jbb4);
pal.add("CENTER",jbb5);
// box2.setLayout(layout);
for(int i=0;i<9;i++)
{
jb[i]=new JButton(String.valueOf(i+1));
box2.add(jb[i]);
// jb[i].addActionListener(this);
}
jb[9]=new JButton("0");
box2.add(jb[9]);
box.add(pal);
box.add(box2);
//添加组件---
cp.setLayout(new FlowLayout());
cp.add(box);
cp.add(pal);
cp.add(box2);
}
}
//应该是此处出现问题的
//不知道要换成什么容器好呢? pal.setLayout(new BorderLayout(5,5)); 因为 Box //只能使用 BoxLayout,使用setLayout()会抛AWTError