Howdy, Stranger!

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


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

killmyrenekillmyrene Member Posts: 2
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:
if event.keyCode == KeyEvent.VK_ESCAPE:
else :
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.


Sign In or Register to comment.