[英]Imported Java applet project into netbeans won't work, Netbeans refuses to identify or even find main class even when manually set
[英]Netbeans Java Interface won't display when called in the main class
我已经在Netbeans中设计了一个Java接口,但是当我尝试在主类中运行它而不是显示它时,则会在屏幕角创建一个空白的新窗口。
这是我的代码:
private static User_Interface myUI = new User_Interface();
public static void main(String[] args) throws InterruptedException, IOException{
SwingUtilities.invokeLater(new Runnable(){
@Override
public void run(){
myUI.setVisible(true);
}
});
}
我已经尝试过根据这个问题提出建议
尽管没有错误,NetBeans Java项目仍不会显示GUI窗口
但是,这仍然无济于事。
接口代码只是设计接口时生成的代码,带有一些setText()方法和空的actionPerformed方法。 它确实扩展了JFrame。
任何帮助都将非常棒,谢谢。
我想.. 布局管理器可能有问题。 将布局设置为null或任何您愿意使用的布局。 在netbeans中,您必须根据需要选择一种布局。 在我的情况下,默认布局为gridBagLayout ,这在解决问题时让我非常痛苦。 只需先检查您的布局即可。 也许可以解决您的问题。
抱歉浪费您的时间,似乎该接口的源代码缺少它的initComponents()方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.