8
CPSC 233 Tutorial 2010

2010-04-04

Embed Size (px)

DESCRIPTION

java

Citation preview

Slide 1

CPSC 233 Tutorial2010Assignment 6Due Apr 15thAn easy assignmentAn email management system:Graphical user interfaceFile reading & writingGraphical User InterfaceGraphical User InterfaceUser friendlyDominating todays computer programsMS WindowsApple Mac OSUnixComposed of (components)Windows, buttons, lists, labels, text fields, check boxes, radio buttons Widget Class Hierarchy

Event-driven programmingprocedural programmingopposed to event-driven programmingprogram runs in pre-scheduled orderEvent-driven programmingprogram responds to events (from user, hardware, network, etc.)Events can occur at anytimeEvents can occur in any orderprogram cannot be pre-scheduledLibrariesimport javax.swing.*import java.awt.event.*Create GUICreate a frame windowJFrame()setSize (, )setBounds(, , , )setVisible ()Add gargets to the frame windowaFrame.add(aButton);buttonstext fields

Handling EventsHandle events of interest to correspond to user inputProceduresStep1: implement event handling routinesextend class WindowAdapterimplement ActionListenerStep2: register event listenersaFrame.addWindowListener(aListener);aButton.addActionListener(aListener);

Event listeners are triggered when corresponding events occur