B.Soflau
B.Soflau

Reputation: 19

Error with JFrame size in Java

With my JFrame I did:

firstFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
firstFrame.setResizable(true);
firstFrame.setVisible(true);
firstFrame.setSize(1680, 1050);
firstFrame.pack();

but just appears a little window in the left-top corner with the exit, minimize and resize buttons. What should I do if I want that the window will appear with this size?

Upvotes: 1

Views: 131

Answers (1)

Nicolas Filotto
Nicolas Filotto

Reputation: 45005

You need to call either pack() or setSize not both, if you decide to call pack() make sure that you have properly added components into your frame and/or that you set the preferred size of your frame using setPreferredSize(Dimension)

Upvotes: 3

Related Questions