
-----------------------------------
The_$hit
Sat Apr 23, 2005 12:23 pm

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)

-----------------------------------
1of42
Sat Apr 23, 2005 12:46 pm


-----------------------------------
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...)

-----------------------------------
Hikaru79
Sun Apr 24, 2005 1:42 pm


-----------------------------------
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?

-----------------------------------
1of42
Sun Apr 24, 2005 9:30 pm


-----------------------------------
Well, HSA console blows, so I don't include it in my generalizations :P

-----------------------------------
Hikaru79
Wed Apr 27, 2005 12:03 am


-----------------------------------
Well, HSA console blows, so I don't include it in my generalizations :P 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.

-----------------------------------
rizzix
Wed Apr 27, 2005 12:19 am


-----------------------------------
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.

-----------------------------------
The_$hit
Wed Apr 27, 2005 8:44 pm


-----------------------------------
oooo ok. Is it possible you make a paint function that you can call?

-----------------------------------
rizzix
Fri Apr 29, 2005 2:54 pm


-----------------------------------
very much possible.. just define ur own function somehting like this:
public void drawMyShape(Graphics g) {
    // do drawing code here
}

and call it soemthing like this: drawMyShape(g); yea just pass it the Graphics object from the paint method..
