I want to draw a simple board made of Graphics2D rectangles but I also want to have one JButton under this board. I know the exact dimensions of this board in pixels and I was t
I want to draw a simple board made of Graphics2D rectangles
When you do custom painting you also need to override the getPreferredSize(...)
method of your component to return the size of the comoponent.
Then the layout manager can use this information and you will not need to use the rigid area.
When you add the components to the frame you can just use the default BorderLayout:
frame.add(board, BorderLayout.CENTER);
frame.add(button, BorderLayout.SOUTH);
I suggest you read the Swing tutorial. There are section on custom painting
and using layout managers
that will provide more detail and examples.