Basic Java GUI problem, JPanel not resizing.
The past days I've been making a paint program to get familiar with graphics in java, I have a functioning program and now I want to be able to save the image.
To accomplish this I've decided add a panel to the frame which I could save, instead of getting the graphics from the whole Frame due to getting the MenuBar and ToolBar as well then.
My frame is generated with the following code
However the JPanel does not cover the full image beneath the JToolBar, I've attached an image showing what it looks like. It shows pretty clearly where the JPanel is limited to.
// Creating and adding stuff to JMenuBar and JToolBar
JPanel malePanel = new JPanel();
Container cp = frame.getContentPane();
malePanel.add(drawShapes); // The shapes are drawn to JPanel instead of frame.
At first I believed it was because I defined the JPanel as final in order to be able to use it in my save function, but removing this and /* */ the save function didn't help.
Adding a GridLayout obviously didn't work as it makes my toolbar half the frame and Panel half the frame. :(
I want the JPanel to cover all of the area beneath the JToolBar, how can I accomplish this?