Allah Rakha
Allah Rakha

Reputation: 65

Spacing issue in JLabel in JPanel

I have a problem related to spacing in labels. there are four labels which are placed in a panel , 1st contain image while other contain plane text. I used Grid Layout because I want them in line by line but wanting no space between labels. How I can do ...........? help me. This is code.!

https://i.sstatic.net/Vnggr.png

and I have the following result.!

https://i.sstatic.net/mRi60.png

Upvotes: 0

Views: 182

Answers (2)

Muhammad
Muhammad

Reputation: 7324

All cells in GridLayout have equal size. You have to use GridBagLayout or SpringLayout or BoxLayout .

Upvotes: 0

camickr
camickr

Reputation: 324147

Don't use a GridLayout because a GridLayout makes all components the same size so you get the spacing that you see.

You might try a vertical BoxLayout. Check out the section from the Swing tutorial on Using Layout Managers for more information and examples.

Upvotes: 3

Related Questions