GUI Programming using Java - Key Events Department of Computer and Information Science, School of Science, IUPUI GUI Programming using Java - Key Events Dale Roberts, Lecturer Computer Science, IUPUI E-mail: droberts@cs.iupui.edu
11.16 Key-Event Handling KeyListener interface For handling KeyEvents Declares methods keyPressed, keyReleased and keyTyped
Outline KeyDemoFrame .java (1 of 3) Implement KeyListener interface Set background color Register application as event handler for itself
Get code of released key Outline Declare keyPressed method Get code of pressed key KeyDemoFrame .java (2 of 3) Declare keyReleased method Get code of released key Declare keyTyped method Get character typed
Outline KeyDemoFrame .java Test if it was an action key Determine any modifiers pressed
Outline KeyDemo.java (1 of 2)
Outline KeyDemo.java (1 of 2)
Acknowledgements Deitel, Java How to Program