程序如下:import java.awt.*;
import javax.swing.*;
/*
* Created on 2005-5-16
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*//**
* @author L.H.F
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class ST { /**
*
*/
public ST() {
super();
// TODO Auto-generated constructor stub
}
/*
* STFrame
*/
class STFrame extends JFrame{
public STFrame(){
setTitle("hello");
setSize(500,400);
STPanel panel=new STPanel();
Container contentPane=getContentPane();
contentPane.add(panel);
}
}
class STPanel extends JPanel{
public STPanel(){
}
public void paintComponet(Graphics g){
super.paintComponent(g);
g.drawString("hello",40,50);
}
}
public static void main(String[] args) {
ST tt=new ST();
STFrame frame=tt.new STFrame();
frame.show();
}
}
问题在什么地方呢?
import javax.swing.*;
/*
* Created on 2005-5-16
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*//**
* @author L.H.F
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class ST { /**
*
*/
public ST() {
super();
// TODO Auto-generated constructor stub
}
/*
* STFrame
*/
class STFrame extends JFrame{
public STFrame(){
setTitle("hello");
setSize(500,400);
STPanel panel=new STPanel();
Container contentPane=getContentPane();
contentPane.add(panel);
}
}
class STPanel extends JPanel{
public STPanel(){
}
public void paintComponet(Graphics g){
super.paintComponent(g);
g.drawString("hello",40,50);
}
}
public static void main(String[] args) {
ST tt=new ST();
STFrame frame=tt.new STFrame();
frame.show();
}
}
问题在什么地方呢?
public void paintComponet(Graphics g){
改成
public void paintComponent(Graphics g){