1

I have 3 JPanel, the first is the base panel and the other two are added to the first. I have realised that there is a lot of space that is not used, shown by the black color and the white color around components.

How do you remove this space?

alt text

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
n002213f
  • 7,805
  • 13
  • 69
  • 105
  • What LayoutManager are you using? – kgiannakakis May 28 '09 at 10:14
  • @willcodejavaforfood - Thanks, got the idea. I'm using FlowLayout and created the layout using new FlowLayout(FlowLayout.LEFT, 0, 0). It works, i just need to change the font styles and sizes – n002213f May 28 '09 at 10:31

1 Answers1

7

If you are using either GridLayout or BorderLayout they both have methods to change the space between components.

In GridLayout this can be done in the 4 int parameter consturctor and in BorderLayout the 2 int parameter constructor. Both LayoutManagers have the methods setHgap and setVgap.

If you are using GridBagLayout you need to make sure that the insets on the GridBagConstraints is changed to whatever you need. Guessing you are using one of the other managers though.

willcodejavaforfood
  • 43,223
  • 17
  • 81
  • 111