Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / June 2006

Tip: Looking for answers? Try searching our database.

Best Layout?

Thread view: 
bcr07548@creighton.edu - 26 Jun 2006 06:50 GMT
Hi everyone.  I am kind of new to Java in general, much less Swing, but
I am working on a project where I want to create somewhat of a flow
chart with draggable boxes and lines connecting them.  I plan on
representing each box in the "flow chart" with a JPanel.  Keeping in
mind that I will need to draw lines between panels, what would be the
best layout to use?  What I am looking for is a layout where I can say
"put panel A at location (X,Y)" but Sun's explanation of layouts didn't
seem to explain anything like that.  If anyone has any input, I would
appreciate it.

-Brandon
IchBin - 26 Jun 2006 07:41 GMT
> Hi everyone.  I am kind of new to Java in general, much less Swing, but
> I am working on a project where I want to create somewhat of a flow
[quoted text clipped - 7 lines]
>
> -Brandon

You may want to look at these examples in the Sun JDK sample Demo
Applets subdirectories. They maybe a little to hard being you are new to
java.

..\jdk1.5.0_07\demo\applets\DrawTest     (example1)
..\jdk1.5.0_07\demo\applets\GraphLayout  (example1 to example4)

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor,  Regular Guy (1952-)
bcr07548@creighton.edu - 27 Jun 2006 05:58 GMT
Is there really no layout that allows you to position a component using
(X,Y) coordinates instead of "directions" like north and center, or
resorting to a more rigid system like a grid?  If there isn't such a
system, then what is the purpose of methods like setLocation(x,y) ?!

I think the GraphLayout example was on the right track but is a little
more roundabout than I was hoping for.  Although a flowchart is
probably the best way of describing the style I am after (draggable
panels connected by lines,) I have something a little more custom in
mind and I would like the boxes to be more like a standard JPanel that
I can add other widgets to.  I suppose I could do something like the
demo did and draw everything myself but I feel like I would be
reinventing the wheel.

-Brandon

> > Hi everyone.  I am kind of new to Java in general, much less Swing, but
> > I am working on a project where I want to create somewhat of a flow
[quoted text clipped - 17 lines]
> Thanks in Advance...
> IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
David Segall - 27 Jun 2006 09:32 GMT
>Is there really no layout that allows you to position a component using
>(X,Y) coordinates instead of "directions" like north and center
You are not compelled to use any layout manager. See
<http://java.sun.com/docs/books/tutorial/uiswing/layout/none.html>
bcr07548@creighton.edu - 27 Jun 2006 23:02 GMT
Just what I was looking for.  I was unsure at first because everything
online discourages it (including Sun) but I tried it out late last
night and ended up playing around with it a bit today too.  Thanks for
the reply.

> >Is there really no layout that allows you to position a component using
> >(X,Y) coordinates instead of "directions" like north and center
> You are not compelled to use any layout manager. See
> <http://java.sun.com/docs/books/tutorial/uiswing/layout/none.html>
Oliver Wong - 29 Jun 2006 16:42 GMT
[post re-ordered]

>> >Is there really no layout that allows you to position a component using
>> >(X,Y) coordinates instead of "directions" like north and center
[quoted text clipped - 3 lines]
> Just what I was looking for.  I was unsure at first because everything
> online discourages it (including Sun)

   The reason LayoutManagers are encouraged is that the layout of the GUI
widgets in most applications are similar to most other applications. In
North American locales, you typically have the menu at the top, labels to
the left of the text fields that they're describing, and both layouts and
text fields are wider than they are tall, etc. There's sort of an "expected
look" for these widgets to have.

   The reason manual laying-out is discouraged is that most developers
don't have enough experience with cross-platform and cross-locale GUI
design. In some locales, the reading-orientation is right-to-left instead of
left-to-right, and so the labels should appear to the right of the text
fields that they are describing. Perhaps in other locales, text is read
vertically, and so labels should be taller than they are wide, etc. On OSX,
the buttons have rounded corners, and thus the buttons have to be wider
(have more padding) so that the text would fit on them, compared to WinXP.

   By using a LayoutManager, you can ensure that your GUI "looks right"
across all of these locales and platforms. If you do it manually, you'll
have to implement the checks for different locales and operating systems
yourself.

   In your case, there is no "expected look" for your widget. You want the
user to be able to click and drag the widgets around manually. So a layout
manager would only be getting in the way.

   - Oliver
andrewthommo@gmail.com - 29 Jun 2006 17:54 GMT
> [post re-ordered]
>
[quoted text clipped - 7 lines]
>
>     The reason LayoutManagers are encouraged
<snip excellent reasons>

Another tack is that once you have the 'logic' of your
layout manager, it takes but a few lines of code to
incorporate it in an 'XYLayout' manager.

Further, I'm not sure if this has been mentioned yet,
but JFreeChart may be a better way to achieve the
overall effect the OP is after.

Andrew T.
Boris Stumm - 26 Jun 2006 10:15 GMT
> Hi everyone.  I am kind of new to Java in general, much less Swing, but
> I am working on a project where I want to create somewhat of a flow
[quoted text clipped - 5 lines]
> seem to explain anything like that.  If anyone has any input, I would
> appreciate it.

Have a look at JGraph http://www.jgraph.com/


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.