Python

Moderators: None (Apply to moderate this forum)
Number of threads: 477
Number of posts: 1160

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
[SOLVED]need help implementing timer&keylistener in Jython assignment Posted by killmyrene on 13 May 2011 at 10:13 AM
Hi Im new to Jython and my prof told me to implement a microwave interface using this program so Im kinda stuck with this assignment because of what I stated in OP. I defined a actionlistener for both timer and keylistener but they gave me TypeErrors.



#some codes above
def keypressed(event):
event = KeyEventWorkaround.processKeyEvent(event)
if not event:
return
if event.keyCode == KeyEvent.VK_ESCAPE:
sys.exit(0)
else :
return
def my_timed_task(action_event):
print "Does it work?"

delay = 1000
time = Timer(delay, my_timed_task) # i got error TypeError: javax.swing.Timer(): 2nd arg can't be coerced to java.awt.event.ActionListener
frame = JFrame("Hi")
frame.addKeyListener(keypressed)#i got error TypeError: addKeyListener(): 1st arg can't be coerced to java.awt.event.KeyListener
#some codes below



I look through other peoples' code similar to timer and keylistener but they are all implemented inside a class. I dont want to implement my whole program in a class because im already finished 80% of my assignment and I dont want to waste time redoing it just to be stuck at some point.



Report
Re: need help implementing timer and keylistener in Jython assignment Posted by killmyrene on 14 May 2011 at 10:29 AM
I got the answer thanks to my prof answering to all my questions



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.