Kotlin - handling key events

snotnose

Ars Tribunus Militum
2,747
Subscriptor
My transition from Java to Kotlin has been going smoothly until recently. How do I handle key events in a JTextField? I have 3 problems:

1) Code that compiles never calls the key listener (JTextField.addKeyListener(stuff))
2) Code that I think is right doesn't compile (JTextField.setOnKeyListener(stuff))
3) DuckDuckGo assumes I'm on Android, which I'm not. I don't have any xml files to twiddle, nor an Android ecosystem.

No code fragment as I'm not even sure which path I should be going down.

If you care, my path has been:
1) Learn Java and IntelliJ IDE (good enough)
2) Learn Kotlin (working on it)
3) Learn Android (soon)
4) Profit! (probably not)
 
Last edited: