Thijs Thijs - 2 years ago 124
Java Question

Java null layout & Revalidate

We are making a little game for school, but my group is running into some trouble. We've build our application using a Null layout manager and placing every element on an absolute position. Now we are running into some problems we can't fix on our own.

As soon as we start the application it looks fine, but as well call Minimize the application and restore it all our elements have - what it looks like - their positions removed. This also happens when we call removeAll() followed by Revalidate().

I've lined some screenshots to clarify what I'm talking about. Is there anyone out here who can help us with this?

App working fine on startup:

App failing after a minimize:

Answer Source

Without any code, all I can do is point you to Oracle's Swing A Visual Guide to Layout Managers

Maybe Oracle can help you. Spend a good bit of time (months) studying the tutorial.

Based on your comment. You should never do a removeAll on a JPanel with Swing elements. You should almost never do a removeAll on a JPanel with JPanels. Here's Oracle's Creating a GUI With JFC/Swing.

Maybe Oracle can help you.

Finally, here's an article I wrote that shows you how to put everything Oracle explains together. Hangman Swing GUI.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download