Results 1 to 5 of 5
Thread: gridbaglayout
- 01-27-2008, 12:01 AM #1
Member
- Join Date
- Jan 2008
- Posts
- 16
- Rep Power
- 0
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.
- 01-27-2008, 03:04 AM #2
Member
- Join Date
- Jan 2008
- Posts
- 20
- Rep Power
- 0
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 www.javaadvice.com
- 01-27-2008, 05:57 AM #3
Member
- Join Date
- Jan 2008
- Posts
- 8
- Rep Power
- 0
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();
- 01-27-2008, 06:08 PM #4
Member
- Join Date
- Jan 2008
- Posts
- 16
- Rep Power
- 0
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 06:12 PM.
- 01-27-2008, 08:03 PM #5
Member
- Join Date
- Jan 2008
- Posts
- 8
- Rep Power
- 0
Similar Threads
-
GridBagLayout
By newtojava7 in forum New To JavaReplies: 2Last Post: 03-07-2008, 12:16 AM -
GridBagLayout...please help
By newtojava7 in forum Advanced JavaReplies: 1Last Post: 02-17-2008, 01:16 AM -
Problems with gridBaglayout when I resize the window
By Iyengar in forum AWT / SwingReplies: 1Last Post: 02-16-2008, 11:43 PM -
Need a idea on GridBagLayout
By ddsuresh in forum AWT / SwingReplies: 1Last Post: 01-29-2008, 01:32 AM -
Problem with GridBagLayout
By Daniel in forum SWT / JFaceReplies: 2Last Post: 07-01-2007, 06:57 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks