This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes using metods in a keylistener Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "using metods in a keylistener" Watch "using metods in a keylistener" New topic
Author

using metods in a keylistener

Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
ok...i have this method in my file "fighter.java"



ok, now in the key listener when i press 'A', i want it to call that
method so it will infact draw the fireball if and only if i press 'A'

example:



please help me, i'm really stuck on this'n..

thanks,
Monk


You down with OOP? Yeah you know me!
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
You're going to have to call that method through paint.
Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
so instead of "drawFireball(g);"

i need to put

paint.drawFireball(g);

???

Help?!
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
No. I mean that the parameter list of the drawFireBall method is a Graphics reference. The only place you're going to get the Graphics reference is in the paint method. You'll have to call drawFileBall from paint and send the Graphics context of the Applet or Frame.
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: using metods in a keylistener
 
It's not a secret anymore!