简体   繁体   English

窗口应用程序无法在Eclipse中打开

[英]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.

相关问题 多窗口Java应用程序 - Multi windowed Java application swing 和 jogl 在窗口应用程序中的使用 - swing and jogl usage in a windowed application 隐藏由Java应用程序启动的窗口化应用程序? - Hiding a windowed application launched by a java application? Eclipse没有打开 - Eclipse is not opening 有没有办法防止 Eclipse 在启动 Web 应用程序时打开浏览器? - Is there a way to prevent Eclipse from opening the browser when starting a Web application? 通过右键单击并选择Eclipse应用程序,Eclipse插件开发的新eclipse窗口无法在运行时打开 - Eclipse plugin development new eclipse window not opening on run via right click and select eclipse application 在Glassfish服务器上运行应用程序时,Eclipse无法打开浏览器 - Eclipse not opening browser when running application on glassfish server 在Eclipse中从第二个框架打开主框架(应用程序窗口) - Opening the main frame (application window) from a second frame in eclipse 在Eclipse服务器中运行时,应用程序无法使用War名称中的url打开 - Application not opening with url as in the war name when running in eclipse server Eclipse ADT Android sqlite:应用程序在打开后立即崩溃 - Eclipse ADT Android sqlite: Application Immediately crashes after opening
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM