![]() |
[java] Laying out a form with java gui (ick)
Im currently using GridBagLayout to try and lay out a form such that the user can enter first name, last name, address, city, state, zip, etc
For the main display, i just leave it at default ( BorderLayout ), and what I do is I create each panel individually and then add each panel to some panel called center and add it to my main panel at BorderLayout.CENTER! GAH, enough of panels, heres an easier example: Lets say I want a label with the word Address on it, and then right to its right a JTextField with 15 size: Code:
/********************************** I want them left aligned like the top one, can someone please help me out? :D It would be greatly appreciated. I think Java gui is a pain, and every time I hit run, I say the age old statement, "Hey it shouldnt look like that!" |
And wow, none of the extra spacing I put in the whole document, for the programming section, and for the GUI sample of what I got and what I want did not come out right.. hmmm where'd my spaces go!!
|
Heh, it's hard to see what the problem is exactly. GridBagLayout is not a very friendly layout. ;)
Have you tried more panels using different layouts? Maybe sticking GridLayout on a panel with 'Address:' and '[]', then another with 'City:' and '[]'. That's all I can think of off the top of my head... Hmm. David M |
SunGun: that's what the [code] tag is for.
|
Check out the NetBeans IDE, it comes with a layout called AbsoluteLayout. Lets you layout by pixel location.
|
Thanks for telling me about the [code] tag.. I didnt know there was one lol...
In any event, I finally figured out GridBagLayout after about 4 days, pretty much got it down pat. I can lay out any GUI given to me on paper now, it's so easy to use once you know what your doing. If anyone needs help with it, give me a yell :) As for the AbsoluteLayout, i'll check that out, sounds good :) Thanks for the help guys SunGun |
What you probably want to do is to create a gridLayout with 4 panels in it, each oriented in NW, NE, SW, and SE (not sure of the keywords for those anchor positions), and put your labels and input boxes in each of those. It's kind of like an HTML table if you think about it, but not nearly as simple to set up. (at least in my opinion).
|
Another note about NetBeans: if you right-click on the layout in its Form Editor and choose Customize, you get a sort-of-WYSIWYG layout editor, which is a lot faster than setting up all the parameters by hand once you get used to it.
|
All times are GMT -8. The time now is 06:11 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project