Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-27-2008, 01:01 AM
Member
 
Join Date: Jan 2008
Posts: 16
newtojava7 is on a distinguished road
gridbaglayout
hello,

i'm using gridbaglayout and finding it very frustrating (must use it for assignment).

im using the constrains.gridy which is set to 1 right now, i want it to go a bit lower, so i change it to 2, but it makes the component go much lower than I want it to, and if I go say 1.5 it gives me an error when i compile saying "possible loss of precision."

i just want to move my component a bit lower, i tried GridBagConstraints.SOUTH as well and it has no effect on its location, please help.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-27-2008, 04:04 AM
Member
 
Join Date: Jan 2008
Posts: 20
JAdmin is on a distinguished road
GridBagLayout is the most complex but the most useful layout manager in Swings. When using GridBagLayout, you need to understand GridBagConstraints because the positioning and other aspects like padding etc are adjusted using attributes of this class.

While gridx and gridy are used to specify the row and column values where the components are placed, there are many other parameters that decide the final look and feel. In your case, you may want to look at the 'insets' because this constraint specifies the expernal padding.

You can still use gridy as 1 and add some 'inset' (The value is specified as an Insets object - e.g . new Insets(2,2,2,2) ) to the components to give some external padding. You can adjust the values for top, left, bottom, and right insets to give the necessary padding to your component.

Hope this helps!
__________________
Sincerely, Your friends at
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 01-27-2008, 06:57 AM
Member
 
Join Date: Jan 2008
Posts: 8
riz618 is on a distinguished road
Hey,
If you simply want to get your component lower you must try to put that component on a panel and then put the panel on top of the container. Let me know if that helps.

JPanel panel = new JPanel();
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 01-27-2008, 07:08 PM
Member
 
Join Date: Jan 2008
Posts: 16
newtojava7 is on a distinguished road
thanks to you both, will give it a try!

by the way do you know how to increase and decrease the size of componants in the gridbaglayout?

edit: riz how can I put a component into a panel?

Last edited by newtojava7 : 01-27-2008 at 07:12 PM.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 01-27-2008, 09:03 PM
Member
 
Join Date: Jan 2008
Posts: 8
riz618 is on a distinguished road
Container c = getContentPane();
JPanel NorthPanel = new JPanel();
c.add(NorthPanel);

This should do it..
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
GridBagLayout newtojava7 New To Java 2 03-07-2008 01:16 AM
GridBagLayout...please help newtojava7 Advanced Java 1 02-17-2008 02:16 AM
Problems with gridBaglayout when I resize the window Iyengar AWT / Swing 1 02-17-2008 12:43 AM
Need a idea on GridBagLayout ddsuresh AWT / Swing 1 01-29-2008 02:32 AM
Problem with GridBagLayout Daniel SWT / JFace 2 07-01-2007 07:57 PM


All times are GMT +3. The time now is 09:58 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org