user1667307
user1667307

Reputation: 2071

Using window builder in eclipse

I am using the windows builder in eclipse to create a swing application. However I observe that the auto generated code is kind of confusing me.

       test frame = new test();
       frame.setVisible(true);


public test() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setBounds(100, 100, 450, 300);
        contentPane = new JPanel();
        contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
        contentPane.setLayout(new BorderLayout(0, 0));
        setContentPane(contentPane);
    }

I always thought we needed to create a JFrame and add the panel to it. But here eclipse seems to create a test object using the construcutor and then invoke the frame.setVisible on a class object and it seems to work fine. I thought the frame.setVisible() must always be invoked on a Jframe.

Upvotes: 0

Views: 298

Answers (1)

iTech
iTech

Reputation: 18460

This test class is a JFrame see the class definition and you will find it inherits JFrame so this should clear your confusion.

Upvotes: 1

Related Questions