Computer Science Canada Drawing a line |
Author: | The_$hit [ Sat Apr 23, 2005 12:23 pm ] |
Post subject: | Drawing a line |
does any one know how to call from main, a paint function that draws a line. It wont let me do it beacuse I need to pass a graphics object in the parameters. can some one please help? (i am using Codewarrior 8 and making an App-Applet) |
Author: | 1of42 [ Sat Apr 23, 2005 12:46 pm ] |
Post subject: | |
You've gotta write all drawing stuff in the paint or draw method of an applet as far as I know... (or the paintComponent method of a JPanel...) |
Author: | Hikaru79 [ Sun Apr 24, 2005 1:42 pm ] |
Post subject: | |
1of42 wrote: You've gotta write all drawing stuff in the paint or draw method of an applet as far as I know... (or the paintComponent method of a JPanel...)
Not quite. The_$hit, are you using HSA console or not? |
Author: | 1of42 [ Sun Apr 24, 2005 9:30 pm ] |
Post subject: | |
Well, HSA console blows, so I don't include it in my generalizations |
Author: | Hikaru79 [ Wed Apr 27, 2005 12:03 am ] |
Post subject: | |
1of42 wrote: Well, HSA console blows, so I don't include it in my generalizations Good idea But your earlier statement is still incomplete. You don't need an applet OR a Jpanel to draw. You can use this: http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Graphics.html for example. There are others. Many others. |
Author: | rizzix [ Wed Apr 27, 2005 12:19 am ] |
Post subject: | |
well, ehm, ok the Graphics class is an abstract class. think of it as a pen. .you dont draw on it.. u draw using it.. instead you draw on a component.. the best component for drawing is the java.awt.Canvas. |
Author: | The_$hit [ Wed Apr 27, 2005 8:44 pm ] |
Post subject: | |
oooo ok. Is it possible you make a paint function that you can call? |
Author: | rizzix [ Fri Apr 29, 2005 2:54 pm ] | ||||
Post subject: | |||||
very much possible.. just define ur own function somehting like this:
and call it soemthing like this:
|