0

I'm working on a school project. I am writing Sudoku. A Sudoku block consist of 9x9 blocks. Of those 9x9 blocks the Sudoku is divided into 3x3 blocks (9 of them).

How do I color those 3x3 blocks the same color to be able to see in what block your working in (i.e. background colors)?

Bernhard Barker
  • 54,589
  • 14
  • 104
  • 138

1 Answers1

1

The cells in a JTable can be styled using a custom TableCellRenderer, which provides a flyweight component ( for example a JLabel) to render each cell. When the cell is editable, you also specify a custom TableCellEditor, which may or may not follow the same style as the renderer.

The UI state (such as the current cell you're working on, to color the group of cells) is best kept in a presentation model (can be a simple bean), which is accessible from your cell renderer and editor, to decide how to style the cell.

Peter Walser
  • 15,208
  • 4
  • 51
  • 78