日期:2014-05-20 浏览次数:20956 次
import java.awt.*; public class TestMultiPanel{ public static void main(String[] args){ MyFrame f = new MyFrame("test",300,300,400,300); } } public class MyFrame extends Frame{ MyFrame (String s,int x,int y,int w,int h){ setTitle(s); setLayout(null); Panel p1 = new Panel(null); Panel p2 = new Panel(null); Panel p3 = new Panel(null); Panel p4 = new Panel(null); p1.setBounds(0,0,w/2,h/2); p2.setBounds(0,w/2,w/2,h/2); p3.setBounds(w/2,0,w/2,h/2); p4.setBounds(w/2,h/2,w/2,h/2); p1.setBackground(Color.blue); p2.setBackground(Color.green); p3.setBackground(Color.yellow); p4.setBackground(Color.red); add(p1); add(p2); add(p3); add(p4); setBounds(x,y,w,h); setVisible(true); } }