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("lzy");
setSize(DEFAULT_WINTH,DEFAULT_HEIGHT);
NotHelloWorldPanel panel=new NotHelloWorldPanel();
Container contentPane=getContentPane();
contentPane.add(panel);
}
public static final int DEFAULT_WINTH=300;
public static final int DEFAULT_HEIGHT=200;
}
class NotHelloWorldPanel extends JPanel
{
public void paintCompontnt(Graphics g)
{
super.paintComponent(g);
g.drawString("I love you!",MESSAGE_X,MESSAGE_Y);
}
public static final int MESSAGE_X=75;
public static final int MESSAGE_Y=100;
}
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("lzy");
setSize(DEFAULT_WINTH,DEFAULT_HEIGHT);
NotHelloWorldPanel panel=new NotHelloWorldPanel();
Container contentPane=getContentPane();
contentPane.add(panel);
}
public static final int DEFAULT_WINTH=300;
public static final int DEFAULT_HEIGHT=200;
}
class NotHelloWorldPanel extends JPanel
{
public void paintCompontnt(Graphics g)
{
super.paintComponent(g);
g.drawString("I love you!",MESSAGE_X,MESSAGE_Y);
}
public static final int MESSAGE_X=75;
public static final int MESSAGE_Y=100;
}
public void paintCompontnt(Graphics g){}
改为
public void paint(Graphics g) {}
import javax.swing.*;
import java.awt.*; 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("lzy");
setSize(DEFAULT_WINTH,DEFAULT_HEIGHT);
NotHelloWorldPanel panel=new NotHelloWorldPanel();
Container contentPane=getContentPane();
contentPane.add(panel);
}
public static final int DEFAULT_WINTH=300;
public static final int DEFAULT_HEIGHT=200;
}
class NotHelloWorldPanel extends JPanel
{
public void paint(Graphics g)
{
super.paint(g);
g.drawString("I love you!",MESSAGE_X,MESSAGE_Y);
}
public static final int MESSAGE_X=75;
public static final int MESSAGE_Y=100;
}