Aero
Aero

Reputation: 61

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.

Upvotes: 0

Views: 673

Answers (2)

Aero
Aero

Reputation: 61

Sorry for wasting your time, it appears that the source code for the interface was missing it's initComponents() method.

Upvotes: 0

Faran Yahya
Faran Yahya

Reputation: 238

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.

Upvotes: 1

Related Questions