tags:

views:

39

answers:

1

Hello,

I am a newcomer to Java Swing. I am using the GUI builder of Netbeans.

I have three main panels for three different views in my application. These views can be switched by a menu on the left.

I switch these views by setting one visible and setting the other two invisible. It works but there is a little problem.

In order to achieve this, I had to put three JScrollPanes next to each other horizontally in the GUI builder. Whenever I switch to a view, the small gaps between the visible component and the invisible ones remain when the visible JScrollPane resizes itself to fill the entire window. It makes the application look quite ugly. The same thing happens when I place them vertically.

How can I fix this by using the GUI builder? I can't make changes to the code for the interface design, obviously.

Here is a very crude drawing of the problem, I hope it's clear enough: Link

Using only one JScrollPane is not an option, because they have different layout managers and will have lots and lots of components. It would not be feasible in terms of performance to render everything from the beginning when a user changes the view.

Thanks in advance,

Emre

A: 

Fixed the problem myself.

You can prevent this by right clicking to each JPanel component in Netbeans, choosing "Space Around Component..." from the popup menu and set the corresponding spaces to 0 by hand.

Emre