当前位置: 代码迷 >> J2SE >> 请教:为什么输出还是空白
  详细解决方案

请教:为什么输出还是空白

热度:61   发布时间:2016-04-24 14:27:52.0
请问:为什么输出还是空白
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)
  相关解决方案