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

Username:   Password: 
 RegisterRegister   
 Quick question on Graphics
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
xHoly-Divinity




PostPosted: Sat Apr 01, 2006 3:39 pm   Post subject: Quick question on Graphics

code:

public void draw (int x, int y, Graphics g)
    {
    }


Suppose I did not want to include the Graphics as part of the call method, how would i incorporate it in the body of the method so that I could still draw things using the graphics.

So lets say

code:

public void draw (int x, int y)
    {
    g.fillOval (4, 4, 4, 4);
    }


How would I go about achieving that? I would have to call graphics somewhere within the method, just not 100% sure of the syntax and it is driving me crazy!! :S. Thanks
Sponsor
Sponsor
Sponsor
sponsor
McKenzie




PostPosted: Sat Apr 01, 2006 4:49 pm   Post subject: (No subject)

Assuming it has a legitimate Graphics context (Applet, Frame ...) try
code:
Graphics g = this.getGraphics ();
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  [ 2 Posts ]
Jump to:   


Style:  
Search: