CS 18000 Lecture Notes - Lecture 20: Layout Manager, Event Dispatching Thread

39 views3 pages

Document Summary

Jtextarea: event handling, events connect user to program, sources (from user), keystrokes or mouse actions (buttons & movement, event listeners (program), method in code, processes events generated by the particular widget. Lined to a widget (or other event source: edt: the event dispatch thread. Java gui is controlled by its own thread. Typical scenario: main thread, builds jframe and lays out interface, makes the jframe visible, returns from main method; main thread exits, edi continues running. Invokes listeners to handle events: observers ( listeners ) in java, actionlistener (buttons, mouselistener (component entry/exit, mousemotionlistener (component, documentlistener (text elds, keylistener (text boxes) Itemlistener (check boxes: actionlistener interface, must implement: public void actionperformed(actionevent e) Less common, but allows independent actions on the same button press: using the actionlistener. Technique 1: create a class that implements actionlistener: create object and attach to one or more buttons. Technique 2: create an object of a nested class and attach button.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents