I have a simple Chess board in a JPanel
with GridLayout(8,8)
as layout manager.
I am trying to add panels for the fields' column name and row number.
Right now I've created another panel with BorderLayout
as layout manager, and in this panel I add the board in BorderLayout.CENTER
. Next to the board itself I've added a panels with GridLayout(0,8)
in BorderLayout.SOUTH
and a panel with GridLayout(8,0)
in BorderLayout.WEST
. The rows numbers is perfectly placed next to the board because the number of rows in the left JPanel matches the number of rows in the board, but the column names (A, B, C, D, E, F, G, H) in the JPanel under the board is not placed correctly because of the JPanel in BorderLayout.WEST
.
What can I do to make a proper Chess board with side panels to show the field numbers/names?
I've tried setting the layout for the south panel to GridLayout(0,9)
and have the first field empty, but the width of the left panel is not equal to each field in the board, so it's not a good workaround.