Question: Here is my problem

![enter image description here](https://i.stack.imgur.com/wQrDP.jpg)

How can I get rid of the gap from the inner rectangle box (it is actually the border of the middle JPanel)?

The outter rectangle is a extends JCompoment. Inside it contains three `JPanel`s. Each of them use GridLayout. I even try to setHgap to a negative value in the big rectangle, but it doesn't change anything.

Edit: Sorry the question is not clear. I do want the border, but I don't want the gap between the inner border and outer border. If there is no gap in between, the whole rectangle will represent a class diagram class.

Answer: 
> 
> it is actually the border of the middle JPanel
> 
> 
> 

If it is the border, remove that (`setBorder(null)`).
The issue is probably to do with the preferred height and width set by the GridLayout on the JPanel.

Excerpt from the [documentation](http://download.oracle.com/javase/1.4.2/docs/api/java/awt/GridLayout.html#preferredLayoutSize%28java.awt.Container%29):

> 
> The preferred width of a grid layout is the largest preferred width of
>  any of the components in the container times the number of columns,
>  plus the horizontal padding times the number of columns plus one, plus
>  the left and right insets of the target container.
> 
> 
> The preferred height of a grid layout is the largest preferred height
>  of any of the components in the container times the number of rows,
>  plus the vertical padding times the number of rows plus one, plus the
>  top and bottom insets of the target container.
> 
> 
>