Laying out a form in java

F

frank

Hi,

I'm trying to generate an application that can run as an applet or
standalone. My 'requirements' are a form (done in MSWord) given to me.

My question is this: Is there a community standard approach to doing
this sort of thing? Currently I'm trying to use GridBagLayout and
although it's brutal, there's no other way I can see to layout
checkboxes, textfields, and labels to resemble the appearance of the
form.

Any response to this will be greatly appreciated.

Thanks,
Frank
 
J

Jeffrey Spoon

Hi,

I'm trying to generate an application that can run as an applet or
standalone. My 'requirements' are a form (done in MSWord) given to me.

My question is this: Is there a community standard approach to doing
this sort of thing? Currently I'm trying to use GridBagLayout and
although it's brutal, there's no other way I can see to layout
checkboxes, textfields, and labels to resemble the appearance of the
form.

Any response to this will be greatly appreciated.

Thanks,
Frank

I think NetBeans has a GUI builder which does this more like Windows
Forms in VS. My friend did a very swishy GUI using NetBeans. Certainly
easier than hand coding it without spending a long time going through
the Swing tutorials. I'm not sure what the resulting code will be like,
though.
 
F

Flo 'Irian' Schaetz

frank said:
My question is this: Is there a community standard approach to doing
this sort of thing? Currently I'm trying to use GridBagLayout and
although it's brutal, there's no other way I can see to layout
checkboxes, textfields, and labels to resemble the appearance of the
form.

Personally, I think GridBayLayout is a pita... Forms a more easily done with
other Layout-Managers... For example the Forms-Layout should do the trick,
TableLayout should also be able to do that.

Flo
 
L

Lew

frank said:
Hi,

I'm trying to generate an application that can run as an applet or
standalone. My 'requirements' are a form (done in MSWord) given to me.

My question is this: Is there a community standard approach to doing
this sort of thing? Currently I'm trying to use GridBagLayout and
although it's brutal, there's no other way I can see to layout
checkboxes, textfields, and labels to resemble the appearance of the
form.

Any response to this will be greatly appreciated.

I can't help much with your primary question, except to say that GridBagLayout
is probably the best choice from the JDK. There are other layout managers
around, some of them free, that may make life easier. I am willing to bet that
others here will indicate some of them, and Google (IYF) can help there, too.

I am here to warn about copy-pasting text directly from MS Word documents. I
have been on many projects (particularly Web app projects) where text was
copied from Word to application source via the Windows clipboard. This causes
trouble because Word uses all kinds of characters, usually from the CP1252
character set, like left double-quote and right double-quote, that you might
not realize are there. Pasted into application source, these characters can
fail to render correctly in the target environment.

- Lew
 
A

Andrew Thompson

frank wrote:
....
My question is this: Is there a community standard approach to doing
this sort of thing? Currently I'm trying to use GridBagLayout and
although it's brutal, there's no other way I can see to layout
checkboxes, textfields, and labels to resemble the appearance of the
form.

'nested layouts' will generally allow you to avoid using
the problematic GBL (wait till it encounters a component
with no minimumSize set.. then the 'fun' begins!).

To create a nested layout, you can put a panel where
you might owerwise have put a component (e.g.
BorderLayout.WEST) than make the panel itself a d
ifferent layout. e.g. GridLayout(1,0) would creata an
area suitable for a column of buttons (on the WEST
side of the GUI).

While GBL is powerful (I have seen things done
in GBL that I have never been able to reproduce
with other core layouts) I would tend to only use it
for those situations where 'only GBL will do'.

Andrew T.
 
F

Flo 'Irian' Schaetz

Andrew Thompson said:
While GBL is powerful (I have seen things done
in GBL that I have never been able to reproduce
with other core layouts)

Do you have an example for one of that?

Flo
 
A

Andrew Thompson

Flo said:
Do you have an example for one of that?

(grins) You're not just prepared to take my
word for it? No? Good!

OK.. here's two examples..
<http://www.physci.org/jnlp/PToE.jnlp>
A Periodic Table of the elements.
Just under a meg. to see on-screen, but you
can probably guess the basic layout from the
name, each element is a single JPanel, organised
by a GBL.
I cannot quite recall why it asks for 'full privileges' -
it is part of a jar with other mains that do require
full access, but with no I/O - the PToE should
not need it.

A second classic example, by Knute Johnson..
<http://groups.google.com/group/comp.lang.java.gui/msg/86ad1bc9ecc9fcdc>

Either of these might be made using a custom layout, but
I know of no (practical) combination of nested (core J2SE)
layouts that would satisfy the requirements of the
periodic table, or center that component with no 'stretch'.

Both of them pretty unusual requirements, admittedly.
The first almost unique, the second perhaps good for
centering media that should not be stretched.. or(?)

Andrew T.
 
D

David Segall

frank said:
Hi,

I'm trying to generate an application that can run as an applet or
standalone. My 'requirements' are a form (done in MSWord) given to me.

My question is this: Is there a community standard approach to doing
this sort of thing?
No. Early versions of Java had minimal GUI support and, even now,
there is no standard way of representing a form in Java. I have a list
of the seven IDEs that allow you to lay out a form with a graphical
drag and drop interface at <http://ide.profectus.com.au> and they
consist of four radically different GUI builders. The most popular is
VEP <http://www.eclipse.org/vep/WebContent/main.php> but I suggest you
choose NetBeans <http://www.netbeans.org> and the recently introduced
GroupLayout. NetBeans will assist you to lay out the first version of
your form in a few minutes and tweaking it to resize the way you want
it to won't take more than an hour. However, the result will not be
"standard".
 
F

Flo 'Irian' Schaetz

Andrew Thompson said:
(grins) You're not just prepared to take my
word for it? No? Good!

To be honest, no. I'm just to stupid to read, sorry :) I didn't see the
limitation to "core" layouts you made. With this limitation you're correct -
imho. But personally I never bothered to really learn how to use GBL,
because there were other layouts out there, that were easier to use and
equally powerfull. Anyway, sorry to have bothered you...

Flo
 
A

Andrew Thompson

Flo said:
To be honest, no. I'm just to stupid to read, sorry :)

No need - gave me an excuse to drag those links out,
and air them in public, so where's the downside? ;-)
...I didn't see the
limitation to "core" layouts you made.

Yep. Once we get into custom/non-Sun layouts,
*all* bets are off.

Andrew T.
 
I

Ian Wilson

Lew said:
I can't help much with your primary question, except to say that
GridBagLayout is probably the best choice from the JDK. There are other
layout managers around, some of them free, that may make life easier. I
am willing to bet that others here will indicate some of them, and
Google (IYF) can help there, too.

I like MigLayout a lot, it is free and I found it *very* much easier
than GridBagLayout. http://www.miglayout.com.

I prefer it to JGoodies FormLayout. I'd guess that FormLayout has wider
support, so I'd recommend you look at FormLayout too.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top