Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to ELIMINATE spaces between panels / images (jlabel) in jpanel

807569Jul 22 2006 — edited Jul 22 2006
Hi,
first what i use:
BoxLayout -> add several JPanels with default FlowLayout -> add text/images to them (with for example JLabel.
I want to have ZERO spaces between any object i place inside ... because it will be screen with objects from html ... so i want to be in control of alignment and space between them.

The problem is tha i can not eliminate all spaces ... in fact i was thinking that in default there will be no spaces between for example JPanel and and objects put in it ... but there is.

I managed to eliminate some of the spaces with adding Box.Filler at bottom with maximum size to "move" other visible objects up.
I also played with setMinimumSize etc. but there is still one space left ... and apart from that i would also apreciate hints how can i solve the problem with this spaces in other way (if there is other way).

http://img291.imageshack.us/my.php?image=javamf2.jpg <--- screen

There are three JPanels (with text, with one jlabel and with two jlabels) ... al of course in general JPanel (contentPane).

This is an example .. red/blue is special background to show the panels and spaces left ... orange rectangle is image in jlabel.
The top one is the maximum i managed to do ... so eliminate space under jlabel in jpanel and horizontal spaces .. but there is top space left.
The bottom one show the situation when i dont use setMinimumSize (height of the image) ... then bottom space appears. I can not also eliminate space between Jlabels (images) in the same JPanel.

Hope you will find some solution and enjoy looking for it :D

Greetings,
Michal
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 19 2006
Added on Jul 22 2006
1 comment
510 views