A brief hands-on introduction to the
AWT/
Swing event model: we create a
JButton, register a listener via
addActionListener, and handle it in
actionPerformed. We examine anonymous classes and lambda expressions, popular listeners (
MouseListener/
MouseAdapter,
KeyAdapter,
DocumentListener), build a mini application based on
JFrame,
JButton,
JLabel, look at the call sequence and common mistakes (heavy work in a handler, variable finality in lambdas, a forgotten
addActionListener, removing listeners, using
SwingWorker).