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

请问:为什么输出还是空白
import   javax.swing.*;

import   java.awt.*;

public   class   NotHelloWorld
{
public   static   void   main(String[]   args)
{
NotHelloWorldFrame   frame   =   new   NotHelloWorldFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.show();
}
}

class   NotHelloWorldFrame   extends   JFrame
{
public   NotHelloWorldFrame()
{
setTitle( "NotHelloWorld ");
setSize(DEFAULT_WIDHT,   DEFAULT_HEIGHT);

NotHelloWorldPanel   panel=new   NotHelloWorldPanel();
Container   contentPane=getContentPane();
contentPane.add(panel);
}
public   static   final   int   DEFAULT_WIDHT=300;
public   static   final   int   DEFAULT_HEIGHT=200;
}

class   NotHelloWorldPanel   extends   JPanel
{
public   void   paintComponetn(Graphics   g)
{
super.paintComponent(g);

g.drawString( "Not   a   Hello,   World   program ",
MESSAGE_X,MESSAGE_Y);

}
public   static   final   int   MESSAGE_X=75;
public   static   final   int   MESSAGE_Y=100;
}

------解决方案--------------------
方法名写错
public void paintComponent(Graphics g)