你的代码里没绘制背景的代码 ,而且,你也没有调用父类的方法,去绘制
我帮你改改
public void paint(Graphics g) {
setBackground(Color.cyan);
super.paint(g);
Graphics2D g2 = (Graphics2D) g;
int red, green, blue;
red = 255;
blue = 255;
green = 0;
g2.setPaint(new Color(red, green, blue));
g2.drawString("Welcome to Xi\047an", 25, 75);
showStatus("Current RGB:" + g2.getPaint().toString());
}
this.getContentPane().setBackground(Color.cyan);
就可以了
可以参考这个
http://zhidao.baidu.com/question/263731760.html