[英]Windowed Application not opening in eclipse
Hi I am trying to learn java. 嗨,我正在尝试学习Java。 I wrote a code which opens the string in window but actually it is not opening. 我写了一个代码在窗口中打开字符串,但实际上没有打开。
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);}});
}
}
Thanks in Advance 提前致谢
You have to set it to be visible , using setVisible()
: 您必须使用setVisible()
将其设置为可见 :
Test f = new Test();
f.setVisible(true);
// ...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.