The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
October 2001



This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.


Line Drawing Technolgy

Posted by Matt Gerrans on October 29, 2001 at 3:29 PM

> you don't really leave classes and use another class, and come back.. what you do is call the method (static) of other classes or instantiate the class itself (HAS-A relationship) in the class that you're using.
> if your line coordinates is in another class, create new methods in the other class that returns the coordinate in either Point or any other type of objects that desire, and then u can use those coordinates to draw the lines.

Actually, if you have a class Line, it could have a method draw() (or render(), etc.) that takes a Graphics object and draws itself. That way, in your overridden paintComponent() method, you can iterate through your collection of graphic objects, asking each to draw() itself. (Heh, heh. Now I managed to work this Collections theme into another thead.).

Using static methods would not be appropriate in this case (unless you are talking about a static factory method to generate Line objects).

- mfg

  • ;) Chin Loong October 30, 2001 at 10:08 AM (0)

Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us