- import java.awt.*;
- public class TestMultiPanel {
-
- public static void main(String args[]) {
- new MyFrame2("MyFrameWithPanel",300,300,400,300);
- //My.setLayout (new GridLayout(1,1,1,1));
- }
- }
- class MyFrame2 extends Frame{
- private Panel p1,p2,p3;
- private boolean flase;
- MyFrame2(String s,int x,int y,int w,int h){
- super(s);
- setLayout(null);
- p1 = new Panel(new GridLayout(1,1)); p2 = new Panel(null);
- p3 = new Panel(null);
- //this.setLayout (new GridLayout(2,2));
- p1.setLayout (new GridLayout(1,1));
- p2.setLayout (new GridLayout(1,1));
- p3.setLayout (new GridLayout(1,1));
- setVisible(true);
- p1.setBounds(0,0,w,h/3);
- p2.setBounds(0,h/3,w/3,h/3*2);
- p3.setBounds(w/3,h/3,w/3*2,h/3*2);
- p1.setBackground(Color.BLUE);
- p2.setBackground(Color.GREEN);
- p3.setBackground(Color.YELLOW);
- this.setResizable(flase);
- add(p1,"NORTH");
- add(p2);
- add(p3);
- setBounds(x,y,w,h);
- setVisible(true);
- }
- }
复制代码 就写出了这个代码,、不过不能跟着窗口变化而变化 |