K
KevinSimonson
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>?
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?
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. 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?
Any pointers anybody can give me on this would be greatly appreciated.
Kevin Simonson
"You'll never get to heaven, or even to LA,
if you don't believe there's a way."
from _Why Not_
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>?
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?
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. 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?
Any pointers anybody can give me on this would be greatly appreciated.
Kevin Simonson
"You'll never get to heaven, or even to LA,
if you don't believe there's a way."
from _Why Not_