I'm developing java swing application. I try to add 2 JPanels on my main JFrame.

My main JPanel class:

```
public class DrawingPanel extends JPanel {
    //mouse variables here
    //Point mPt = new Point(0,0);

    public DrawingPanel() {
        setBackground(COLOURBACK);
        MyMouseListener ml = new MyMouseListener();
        addMouseListener(ml);
    }

    public Dimension getPreferredSize() {
    return new Dimension(width, height);
    }
....
....
....
}

```

is working fine when I add as the only component on main frame. But when I try to add another JPanel on the frame my DrawingPanel appears as small white box.

```
private void createAndShowGUI()
    {
        DrawingPanel panel = new DrawingPanel();

        JFrame frame = new JFrame("Hex Testing 4");
        frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
        Container content = frame.getContentPane();
        JPanel aggregationFrame = new JPanel(new GridBagLayout());
        aggregationFrame.add(panel);
        aggregationFrame.add(new JLabel("Enter username:"));
        content.add(aggregationFrame);
        //this.add(panel);  -- cannot be done in a static context
        //for hexes in the FLAT orientation, the height of a 10x10 grid is 1.1764 * the width. (from h / (s+t))
        frame.setSize( (int)(SCRSIZE/1.23), SCRSIZE);
        frame.setResizable(false);
        frame.setLocationRelativeTo( null );
        frame.setVisible(true);
    }

```

It looks like this

[![result](https://i.stack.imgur.com/JyDnU.png)](https://i.stack.imgur.com/JyDnU.png)

I tried to add getPreferredSize() method to DrawingPanel as was suggested in [JPanel appears as a small white box](https://stackoverflow.com/questions/36189948/jpanel-appears-as-a-small-white-box) question but it didn't work well. 

Can you help me with the problem please?

**UPDATE:**

I have changed the layout and now I see a half of my JPanel. I think the problem relates to fixed sizes of JPanels and JFrame. Will investigate it. 

[![update](https://i.stack.imgur.com/pzuLy.png)](https://i.stack.imgur.com/pzuLy.png)