I have been building a Java version of Monopoly in my spare time and am having some trouble understanding layouts etc for Swing.
Each one of my spaces on the board is a essentially a custom JButton and I have been trying to lay them around the edge of a frame (like on the monopoly board itself). I can’t seem to find a useful explanation of how the layout system works and so am having trouble do so.
Could someone please give me an example of how they would lay the buttons around the edge of the frame? Should I be using a different layout?
This seems to lend itself to work best with a
BorderLayout. I would recommend creating 4JPanels that will contain all of theJButtons.Then add the
JPanelsto theBorderLayout.North,South,East, andWest.That seems to me to probably be the easiest way to layout the buttons.
Here is a great place to start using a
BorderLayout.I just threw together some code that may help you get started laying this out. It has not been compiled.