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

Howdy, Stranger!

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

Categories

[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.