We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

GridBagLayout & setting JPanel to appear in specific location

ShamD
ShamD asked
on
Medium Priority
319 Views
Last Modified: 2012-06-27
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
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2016

Commented:
You'll need to post your code, preferably runnable
Mayank SPrincipal Technologist
CERTIFIED EXPERT

Commented:
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).
To distribute the objects ,  set weighty to 1 in the GridBagConstraints

~Hemanth

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
> 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

Author

Commented:
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.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.