aspose file tools*
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


Win a copy of Java 8 in Action this week in the Java 8 forum!
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.
 
 
subject: using metods in a keylistener
 
Similar Threads
Error in one of my classes
inheritance from more that once source....
having protected variables in interfaces?
KeyEvent problem on a JPanel
VK_TAB event not working