flywithmoon
发贴: 44
积分: 0
|
于 2004-08-24 22:56
可以调试通过,但是运行时看不到任何结果。 import java.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; class test extends JFrame { test(){ this.getContentPane().add(new myp()); } public static void main(String args []){ test f=new test(); f.setSize(300,300); f.show(); } } class myp extends JPanel { JPanel p[]; myp() { setLayout(new GridLayout(2,2)); for(int i=0;i<4;i++) {p[i]=new JPanel(); p[i].setBackground(new Color((int)(Math.random()*255),(int)(Math.random()*255),(int)(Math.random()*255))); add(p[i]);} } }
why edited on 2004-08-31 19:51
|