代码:packageJavaLearnning;importjava.awt.*;publicclassTestNesting{privateFramef;privatePanelp;privateButtonbw,bc;privateButtonbfile,bhelp;privateTextAreata;publicvoidcre...
代码:
package JavaLearnning;
import java.awt.*;
public class TestNesting {
private Frame f;
private Panel p;
private Button bw,bc;
private Button bfile,bhelp;
private TextArea ta;
public void creat() {
f = new Frame("容器嵌套");
ta = new TextArea("text area");
bw =new Button ("West");
bc = new Button("Work space region");
f.add(bw,"West");
f.add(bc,"Center");
p =new Panel();
p.setLayout(new BorderLayout());
f.add(p,"North");
bfile =new Button("文件");
bhelp = new Button("帮助");
p.add(bfile,"North");
p.add(bhelp,"West");
p.add(ta,"Center");
f.pack();
f.setSize(500,500);
f.setVisible(true);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
TestNesting gui = new TestNesting();
gui.creat();
}
}
展开