New to swing, need gui layout help

C

CJ

I have been using java for years, now I need to go gui work. I am
having a Dickens of a time trying to grasp the swing layout managers,
specifically how to control placement on screen.

I am not looking for an IDE, but want to gain a better understanding
of the mechanics of how the layout managers "decide" to layout
components. Most references I have found only parrot what the API
javadocs , which are terse as best.

Does anyone have real world examples of laying out java swing UIs?

I am sure I will be flamed for this general, newbie question, assuming
somewhere on this group this question has been asked and answered.
Sorry in advance.

cj
 
E

Eric Sosman

CJ said:
I have been using java for years, now I need to go gui work. I am
having a Dickens of a time trying to grasp the swing layout managers,
specifically how to control placement on screen.

I am not looking for an IDE, but want to gain a better understanding
of the mechanics of how the layout managers "decide" to layout
components. Most references I have found only parrot what the API
javadocs , which are terse as best.

Does anyone have real world examples of laying out java swing UIs?

I am sure I will be flamed for this general, newbie question, assuming
somewhere on this group this question has been asked and answered.
Sorry in advance.

The Java Tutorial at http://java.sun.com/docs/books/tutorial/
is as good a place as any to start learning.

I also found the http://java.sun.com/developer/ article
"Effective Layout Management: Short Course" to be helpful.

If all else fails, Google Java layout manager and browse
the two and a half million hits it turns up. Even if Sturgeon's
Law holds, there's a quarter-million useful links among them.
 
R

RedGrittyBrick

CJ said:
I am sure I will be flamed for this general, newbie question,

You deserve flaming for multiposting instead of crossposting!
http://www.cs.tut.fi/~jkorpela/usenet/xpost.html
assuming
somewhere on this group this question has been asked and answered.

I just answered it in one of the other newsgroups you posted it to.
Sorry in advance.

That doesn't make me feel any better about having wasted my time
unknowingly duplicating what Eric wrote here. This would not have
happened if you'd crossposted instead of multiposted.
 
C

CJ

The Java Tutorial athttp://java.sun.com/docs/books/tutorial/
is as good a place as any to start learning.

I also found thehttp://java.sun.com/developer/article
"Effective Layout Management: Short Course" to be helpful.

If all else fails, Google Java layout manager and browse
the two and a half million hits it turns up. Even if Sturgeon's
Law holds, there's a quarter-million useful links among them.

Thanks Eric. I have been through the sun tutorials. I have also read
many of the "two and a half million hits" google turns up. Most are
just a parrot of the tutorials and none describe the mechanics of
layout managers. Sure if one only needs to write calculators, the
tutorials are extremely useful. But I notice that all IDEs I have
looked into use hand rolled layout managers, indicating the JDK layout
managers are not as useful for more real world apps.

However, the link you provide does move me forward a bit.

cj
 
C

CJ

You deserve flaming for multiposting instead of crossposting!http://www.cs.tut.fi/~jkorpela/usenet/xpost.html


I just answered it in one of the other newsgroups you posted it to.


That doesn't make me feel any better about having wasted my time
unknowingly duplicating what Eric wrote here. This would not have
happened if you'd crossposted instead of multiposted.

All I can say is sorry for the multi post. Accept the apology or not,
no skin off my nose. I am looking for information in a timely fashion
and will proceed with that as my sole goal.

Thanks for the education on posting. And thanks for you suggestion,
but it too does little to enlighten me on the mechanics of layout
managers in java swing.

cj
 
M

Mark Space

CJ said:
Thanks Eric. I have been through the sun tutorials. I have also read
many of the "two and a half million hits" google turns up. Most are
just a parrot of the tutorials and none describe the mechanics of
layout managers. Sure if one only needs to write calculators, the
tutorials are extremely useful. But I notice that all IDEs I have
looked into use hand rolled layout managers, indicating the JDK layout
managers are not as useful for more real world apps.

Actually, the IDE use layout managers that are easy for a programmatic
system to generate code for.

Have you looked into NetBeans? It's layout manager (Spring, I think) is
now standard in Java 1.5 or 1.6 or so. So you don't have to try to add
it to your jars. Just require the latest Java and you're good.

O'Reilly's _Learning Java_ goes into layout managers quite a bit. I
don't know if it has more detail than the tutorials you've looked at,
but if you don't mind one more dead tree on your bookshelf you might
check into it. The explanations are brief but also informative, and
cover most common functionality of the pre-1.4 layout managers. It is
better than the dead simple make-a-calculator examples I've seen.

I can't really talk about any other Swing GUI books. LJ is all I own...

Good luck.
 
M

Martin Gregorie

CJ said:
I have been using java for years, now I need to go gui work. I am
having a Dickens of a time trying to grasp the swing layout managers,
specifically how to control placement on screen.

I am not looking for an IDE, but want to gain a better understanding
of the mechanics of how the layout managers "decide" to layout
components. Most references I have found only parrot what the API
javadocs , which are terse as best.

Does anyone have real world examples of laying out java swing UIs?
I've seen a lot of examples using nested Box layouts, which seems to
work tolerably well, e.g. making rows with horizontal Box layouts and
then stacking those in a vertical Box layout.

For dialogue windows, e.g. where each line is a JLabel and a JTextField
or JTextArea, I've had good results with the 3rd party RiverLayout
layout manager:

http://www.datadosen.se/riverlayout/
I am sure I will be flamed for this general, newbie question, assuming
somewhere on this group this question has been asked and answered.
Sorry in advance.
I think layout managers is a difficult area to get a handle on when
you're starting to use a GUI interface.
 
D

David Segall

CJ said:
I have been using java for years, now I need to go gui work. I am
having a Dickens of a time trying to grasp the swing layout managers,
specifically how to control placement on screen.

I am not looking for an IDE, but want to gain a better understanding
of the mechanics of how the layout managers "decide" to layout
components.
The authors of the NetBeand IDE undertook a similar task when they
tried to "explain" a complex GUI layout to a computer. They decided
that none of the existing layout managers was up to the task and
devised a new one. I have not tried to use it directly but from other
posts it seems that the resulting Group Layout is not suitable for
human coders.

Consider the possibility that a modern GUI is sufficiently complex to
require a graphical design tool rather than a traditional, text based,
specification. Even if you ultimately reject an IDE you may find it
useful in gaining a better understanding of layout managers because it
will instantly show you the result of changing from one layout manager
to another.
 

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,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top