您好我正在尝试学习java。我写了一个代码,在窗口中打开字符串,但实际上它没有打开。
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class Test extends Frame {
public void paint(Graphics g){
g.drawString("Hello from Java",60,100);
}
public static void main(String args[]){
Test f = new Test();
f.setSize(200,200);
f.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);}});
}
}
先谢谢