简体   繁体   中英

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.!

http://i.stack.imgur.com/Vnggr.png

and I have the following result.!

http://i.stack.imgur.com/mRi60.png

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM