This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes formatting the GUI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "formatting the GUI" Watch "formatting the GUI" New topic

formatting the GUI

Jason Richard
Ranch Hand

Joined: Oct 05, 2007
Posts: 79
Hi All,

I'm creating a GUI to sit on top of some already existing code. I'm doing it by hand, and staying away from the Netbeans auto gen stuff, because quite frankly my experience is they cause more problems then they solve.


In this effort I'm trying to stick with with the basic layout structures (Border/Grid). I'm using GridBag in very SMALL Areas because quite frankly I can't seem to get things to go how/where I want them on any sort of bigger panel.

I'm having a hard time getting things (most notably JTextFields) to be the size i want them to be. What I have been doing to adjust for this is creating blank panels and inserting them as needed to shrink things down. For example I might want four JTextlabels and four TTextFields in the upper left quadrant of a panel, so I'll add those items to it's own panel using a Grid Layout (2,2) and add that panel to another grid layout on another panel (2,2) I would then add 3 blank panels as either placeholders for things in the future, or simply for the blank space.

Is this a bad/unacceptable practice? IS there something better I should be doing?

Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4351

bad/ unacceptable? not as far as i know. there are many other features of swing some others might help you with. you can use horizontal glue for instance to space something over to the other side with blank in the middle. you can also set the preferred size of components to make them smaller for instance.

Visit my download page
Jason Richard
Ranch Hand

Joined: Oct 05, 2007
Posts: 79
It would seem that Box Layout is going to be helpful as well. Oh why did I ignore thee to start??
I agree. Here's the link:
subject: formatting the GUI
It's not a secret anymore!