This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes draw method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "draw method" Watch "draw method" New topic
Author

draw method

Adewale Adebusoye
Ranch Hand

Joined: Sep 28, 2005
Posts: 118
Hello..im trying to implement method called draw1() to draw recursive shapes. Since its for an assignment the function has to be in this format

draw( Point p1, Point p2, Point p3, int n, JFrame w)

My main problem is passing the JFrame as an arguement to this method.
How can i draw on JFrame w since im passing it as an arguement?
Please help. I mean i know i got to use paintComponent() but i cant access it directly from JFrame w.
And im not sure if i can use Graphics g anywhere other than paintComponent().
Thanks


"Human beings can alter their lives by altering their state of mind" William James
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
Maybe this will give you some ideas.

Another, less–effective way to do this might be

and to eliminate this

from the drawPoints method.
It would work but it is a one–time event. Cover/uncover or minimize/restore the JFrame and the drawing is damaged/gone.
 
Consider Paul's rocket mass heater.
 
subject: draw method
 
Similar Threads
Defining the exact bottom of panel for graphic component
flicker in my program
JPanel vs. JFrame
How to draw circles whose center coordinates are stored in an array?
painting custom components without extending jcomponent