我需要有关它不起作用的paintComponent的帮助,请帮助:( ps:我有所有的进口......
public JavaGame() {
setVisible(true);
setSize(500, 500);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setResizable(false);
setLocationRelativeTo(null);
setTitle("Java Game");
}
public void paintComponent (Graphics g)
{
super.paintComponents(g);
g.drawString("Hello World!", 20, 20);
}
public static void main(String[] args) {
new JavaGame();
}