GridBagLayout and JFrames/JPanels!
Hey everyone, first post here, so hello! =)
Anyways, I am making a level editor for my game.
On a JFrame I am trying to organize 5 components (A JPanel component called Map that just overrides paintComponent() method to draw the map), 2 JButton's, a JComboBox, and a JLabel. I organized the buttons and the JComboBox into its own JPanel via GridBagLayout and then added it to my JFrame (800x600, btw) by using
and the graphics panel containing the JPanel object called Map that overrides paintComponent() in it's own JPanel using GridBagLayout by doing
I have figured out GridBagLayout and have set the size of all the elements on the screen and organized them correctly using setPrefferedSize() and the GridBagConstraints.
So, basically, I add the Graphics object to the top of the frame and the button panel object to the bottom of the frame, and everything works!
Except, when I call repaint on the Map object, map is suddently resized and overlaps the buttons on the botton! (BorderLayout.SOUTH)
Any suggestions? Sorry, putting code to demonstrate this would be complicated.
Thanks for the help, also this may belong in 2d, sorry if it does!
PS, Images may help! Here you go:
Before (This is how I want it to look even after calling repaint)
After (When calling repaint to update the screen, this happens :( )