简体   繁体   中英

Netbeans Java Interface won't display when called in the main class

I have designed a Java Interface in Netbeans, however when I try to run it in the main class, instead of displaying, a blank new window is created in the corner of the screen.

This is my code:

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);
        }
    });
}

I have already tried to implement advice from this question

NetBeans Java Project Won't Display GUI Window Despite No Error

however this still doesn't help.

The interface code is all just the generated code from designing the interface, with a few setText() methods and empty actionPerformed methods. It does extend JFrame though.

Any help would be fantastic, thanks.

I guess.. There may be an issue with your layout manager . Set the layout to null or any other with which you are comfortable. In netbeans you have to select a layout according to your need. In my case the default layout was gridBagLayout that was alot pain for me while resolving the issue. Simply check your layout first. May be that resolves your issue.

抱歉浪费您的时间,似乎该接口的源代码缺少它的initComponents()方法。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM