In article
<a3b93942-5710-4717-bb36->,
KevinSimonson <> wrote:
> I haven't done anything with Swing for a while, and decided I wanted
> to brush up my skills, so I thought I'd write a Java program that
> drew lines on a <JPanel> on a <JFrame>. Does anybody know how to get
> ac- cess to a <JPanel> on a <JFrame>? What the steps are to draw the
> lines that show up in the <JPanel> on the <JFrame>?
Definitely start with the tutorial:
<http://java.sun.com/docs/books/tutorial/uiswing/>
> I think that I want to modify one of the <paint()> or
> <paintComponent()> methods of the <JPanel>, and do <drawLine()> calls
> with its <Graphics> object. Does anybody know what the difference is
> between modifying <paint()> and <paintComponent()> so I can know
> which I want to use?
<http://java.sun.com/docs/books/tutorial/uiswing/painting/index.html>
<http://java.sun.com/products/jfc/tsc/articles/painting/>
> I'd also like to have some code that changes the lines that are drawn
> depending on where the user clicks the mouse. If I remember right I
> need to make my <JPanel> object implement an interface in order for
> that to happen, and the interface will include some methods that get
> called when the user clicks the mouse.
Here's a simple object drawing example:
<http://sites.google.com/site/drjohnbmatthews/graphpanel>
> And is there another interface that defines the methods that get
> called when the user _resizes_ the <JFrame>, so that I can have my
> application draw the <JPanel> with the new size? And when the user
> _moves_ the <JFrame>, so that I can have my application redraw the
> <JPanel> in its new location?
Look at using a layout manager and component listener:
<http://java.sun.com/docs/books/tutorial/uiswing/layout/index.html>
<
http://java.sun.com/docs/books/tutor...ponentlistener
..html>
--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>