int n = nQueens.getN();
List<Queen> queenList = nQueens.getQueenList();
setLayout(new GridLayout(n, n));
for (int row = 0; row < n; row++) {
for (int column = 0; column < n; column++) {
Queen queen = queenList.get(column);
if (queen.getColumn().getIndex() != column) {
throw new IllegalStateException("The queenList is not in the expected order.");
}
String toolTipText = "row " + row + ", column " + column;
if (queen.getRow() != null && queen.getRow().getIndex() == row) {
JButton button = new JButton(new QueenAction(queen));
button.setMinimumSize(new Dimension(20, 20));
button.setPreferredSize(new Dimension(20, 20));
button.setToolTipText(toolTipText);
add(button);