日期:2014-05-20  浏览次数:20698 次

没事,写了一个Frame的小屁程序,居然不成功!

只显示窗体,没有内容。

package print1;
import java.awt.*;

public class TestPaint {
public static void main(String[] args){
new MyFrame().launchFrame();
}
}


@SuppressWarnings("serial")
class MyFrame extends Frame{

public void launchFrame(){
this.setBounds(200, 200, 300, 400);
this.setBackground(Color.BLACK);
this.setVisible(true);
//this.setTitle("first Frame!");

}

@Override
public void print(Graphics g) {
g.setColor(Color.WHITE);
g.fillOval(50, 50, 30, 40);
g.fillRect(80, 80, 40, 40);

//super.print(g);
}
}

------解决方案--------------------
窗体绘制的方法名是paint,不是print,把你的print方法改成paint就行了。