Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Drawing a line
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
The_$hit




PostPosted: 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)
Sponsor
Sponsor
Sponsor
sponsor
1of42




PostPosted: Sat Apr 23, 2005 12:46 pm   Post subject: (No 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...)
Hikaru79




PostPosted: Sun Apr 24, 2005 1:42 pm   Post subject: (No 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?
1of42




PostPosted: Sun Apr 24, 2005 9:30 pm   Post subject: (No subject)

Well, HSA console blows, so I don't include it in my generalizations Razz
Hikaru79




PostPosted: Wed Apr 27, 2005 12:03 am   Post subject: (No subject)

1of42 wrote:
Well, HSA console blows, so I don't include it in my generalizations Razz
Good idea Smile 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




PostPosted: Wed Apr 27, 2005 12:19 am   Post subject: (No 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.
The_$hit




PostPosted: Wed Apr 27, 2005 8:44 pm   Post subject: (No subject)

oooo ok. Is it possible you make a paint function that you can call?
rizzix




PostPosted: Fri Apr 29, 2005 2:54 pm   Post subject: (No subject)

very much possible.. just define ur own function somehting like this:
code:
public void drawMyShape(Graphics g) {
    // do drawing code here
}


and call it soemthing like this:
code:
drawMyShape(g);
yea just pass it the Graphics object from the paint method..
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 8 Posts ]
Jump to:   


Style:  
Search: