I am writing a program to solve Sudoku puzzles. I create the user interface using AWT/Swing.
One panel of the main window (JFrame object) contains a Graphics2D component only (a grid for the sudoku puzzle). The problem is that this panel is too small for its contents when it is created. I have tried many things to make it bigger (like the setSize method of the panel), but to no avail. Who can tell me how I can make the panel with a single Graphics2D object larger?
Below is the code for the main window, which is a JFrame object. I set its size to 400 x 400 to have ample room for all panels. I then create two panels: a sudoku panel that contains the sudoku grid and a button panel that contains two buttons. The button panel has a flow layout.
I then create the main panel. This has a vertical BoxLayout. Finally I add the sudoku panel and the button panel to the main panel and the main panel to the frame.
Below is the code for the SudokuPanel class.
When I run the program, the following Window shows up:
As you can see, the button panel is exactly in the middle (and it remains in the middle, no matter how I resize the window). And there is not enough room for the sudoku panel.
How can I make enough room for the sudoku panel when the window is created?