Reputation: 1224
I am trying to make something like the above, a frame that consists of many JButton
components (gray rectangles). These buttons are of the exact shape but their positioning looks like the picture. I am new to AWT
, Swing and such and don't know what layout should I use, I know a bit of GridLayout
and BorderLayout
which are obviously not suitable in this case.
Any ideas?
Upvotes: 1
Views: 99
Reputation: 148
I strongly recommend you to use Grid Bag Layout, with this layout you can make good looking GUI or strange GUI in most cases. In your problem Check insets in Grid Bag layout, this layout is kind of tricky but if you will learn it, you will see that it is simple.
Upvotes: 2
Reputation: 3313
I think its better to use GridBagLayout. GridBagLayout is a sophisticated, flexible layout manager. It aligns components by placing them within a grid of cells, allowing components to span more than one cell. The rows in the grid can have different heights, and grid columns can have different widths. For further details, see How to Use GridBagLayout. For more details - https://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html#gridbag
Upvotes: 2