ShamD
asked on
GridBagLayout & setting JPanel to appear in specific location
Hi,
I am using the gridbagLayout. I have a JPanel, a JTable, and another JPanel in that appear in that order down the screen.
The problem is, I want the first JPanel to appear nearer the top left hand corner of the screen, It appears 1/2 way down the screen. Which forces the JTable further down.
Can I fix the setting of this JPanel.
I tried setLocation(10,10); but it didnt solve it for me.
Could anyone offer advice.
Sham
I am using the gridbagLayout. I have a JPanel, a JTable, and another JPanel in that appear in that order down the screen.
The problem is, I want the first JPanel to appear nearer the top left hand corner of the screen, It appears 1/2 way down the screen. Which forces the JTable further down.
Can I fix the setting of this JPanel.
I tried setLocation(10,10); but it didnt solve it for me.
Could anyone offer advice.
Sham
You'll need to post your code, preferably runnable
Did you put it in a scroll-pane? If yes, then you need to set the location/ bounds to the scroll-pane (not to the panel).
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
> I tried setLocation(10,10); but it didnt solve it for me.
to set the location you need to use null layout manager.
And you'll also need to set the size
to set the location you need to use null layout manager.
And you'll also need to set the size
ASKER
Thanks for your responses.
I just needed to alter my GridbagConstraints inputs.
I wasnt sure how to use them before and what they all meant.
I just needed to alter my GridbagConstraints inputs.
I wasnt sure how to use them before and what they all meant.