Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

[SOLVED]need help implementing timer&keylistener in Jython assignment

killmyrenekillmyrene Posts: 2Member
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.

[hr]
#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
[hr]

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.



Comments

Sign In or Register to comment.