wood burning stoves 2.0*
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 agree. Here's the link: http://aspose.com/file-tools
 
subject: using metods in a keylistener
 
Similar Threads
VK_TAB event not working
inheritance from more that once source....
KeyEvent problem on a JPanel
having protected variables in interfaces?
Error in one of my classes