赞
踩
达到如图所示效果
- package com.han.lesson01;
-
- import java.awt.*;
-
- public class ExDemo {
- public static void main(String[] args) {
- Frame frame=new Frame();
- frame.setSize(400,300);
- frame.setLocation(300,400);
- frame.setBackground(Color.black);
- frame.setVisible(true);
- frame.setLayout(new GridLayout(2,1));
-
- //四个面板
- Panel p1=new Panel(new BorderLayout());
- Panel p2=new Panel(new GridLayout(2,1));
- Panel p3=new Panel(new BorderLayout());
- Panel p4=new Panel(new GridLayout(2,2));
-
- p1.add(new Button("East-1"),BorderLayout.EAST);
- p1.add(new Button("West-1"),BorderLayout.WEST);
- p2.add(new Button("p2-btn-1"));
- p2.add(new Button("p2-btn-2"));
- p1.add(p2,BorderLayout.CENTER);
-
-
-
- p3.add(new Button("East-2"),BorderLayout.EAST);
- p3.add(new Button("West-2"),BorderLayout.WEST);
- for(int i=0;i<4;i++){
- p4.add(new Button("for-"+i));
- }
- p3.add(p4,BorderLayout.CENTER);
- frame.add(p1);
- frame.add(p3);
-
- }
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。