Tyler
Tyler

Reputation: 506

Java 8 - Why does JFrame move?

I recently updated to JDK and I've come across a very strange problem. I have a JFrame that I call the method setLocationRelativeTo(parentJFrame) and for some reason the JFrame flashes to the correct position before jumping to the top left of my screen and slowly slides down until it hits the bottom of the screen. Why does it do this, and how can I fix it?

Upvotes: 0

Views: 172

Answers (1)

MadProgrammer
MadProgrammer

Reputation: 347334

Make sure you call setVisible last, after you've initialised the UI and defined its size and position, preferably using pack and setLocationRelativeTo

Upvotes: 2

Related Questions