CPSC 233 Study Guide - Final Guide: Binary File, Parsing, Subtyping

387 views19 pages

Document Summary

Abstract window toolkit and swing packages give support for building guis. Layout managers -> govern how components appear in a window. Handle events generated by user such as; mouse click, key press. Drawing graphics, reading and displaying image files, printing, etc. Create control objects (e. g. button and set its properties) -> Implement an interface to handle events generated by these controls (create a handler class) Add controls to a container (use layout managers to determine the positions) Asynchronus: you cannot prdict when input will happen. User action -> window manager -> event -> event handler. Supply an appropriate event handler for each possible event in your program. Particular objects handle particular events (based on delegation) Creating a control => registering the delegate object (adding a listener) import javax. swing. import java. awt. event. public class demo { public static void main (string args[ ]) { System. exit(0); public class myhandler implements windowlistener { public void windowclosing(windowevent e) { (cid:862)other wi(cid:374)do(cid:449)liste(cid:374)er (cid:373)ethods(cid:863) { }