Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 02 Apr 1999 13:50:07 -0500 (EST)
From:      John Baldwin <jobaldwi@vt.edu>
To:        java@freebsd.org
Subject:   Swing help, please...
Message-ID:  <XFMail.990402135007.jobaldwi@vt.edu>

next in thread | raw e-mail | index | archive | help
I hope ya'll don't mind me asking a Java-related question on here.  I'll keep
it short:

For a project I am working on, I am using Swing to display a program that deals
with graphs and graph theory (algorithms, etc.) and am having problems labeling
the points on the graph.  I've tried reading the docs on Sun's site, but I
still have some questions.  I'm trying to label the graph points via JLabels,
btw.  The graph itself is currently drawn manually via calls to a Graphics
object inside of an extended JPanel's paintComponent().  When a new point is
created, I create a new JLabel and add() it to the extended JPanel().  However,
it doesn't actually draw itself until the window is forced to repaint (such as
when the JInternalFrame containing the graph is resized).  Shouldn't it just
draw itself when it is added in or do I manually need to call something else,
like label.repaint()?  Secondly, I want the labels to be "attached" to the
Vertices of the graph and thus to follow them around.  However, with a
FlowLayout, they just ignore the location I provide for them in setLocation(). 
So, I turned off the LayoutManager for the panel, and now they don't display at
all.  I'm guessing that I need to set their size manually, in which case, how
do I figure out how much room a string is going to take up so that I can give
the label an accurate size?  Thanks.

P.S., If anyone knows of good resources I can go to for help with these
questions I'd really appreciate it.  Thanks.

---

John Baldwin <jobaldwi@vt.edu> -- http://members.freedomnet.com/~jbaldwin/
PGP Key: http://members.freedomnet.com/~jbaldwin/pgpkey.asc
"Power Users Use the Power to Serve!"  -  http://www.freebsd.org


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-java" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.990402135007.jobaldwi>