LETU COSC 2103 - Graphical User Interface Components: Part 1

Unformatted text preview:

Graphical User Interface Components: Part 1Graphical User Interface (GUI)Netscape Window With GUI ComponentsSome Basic GUI ComponentsThree Parts of a GUI ApplicationSwing GUI ComponentsOverview of Swing ComponentsEvents Generated by Swing ComponentsSlide 9JLabelEvent HandlingSlide 12Some Event Classes Of Package java.awt.eventEvent Handling ModelEvent Listener ObjectWhat is an Event Listener?What If …?Event-listener Interfaces Of Package java.awt.eventTextfieldsHow Event Handling WorksSlide 21Event Registration for JTextField textField1JButtonSwing Button HierarchyJButton ExampleComments on JButtonThe paint Method RevisitedAn Example of PaintingSlide 29JCheckBox and JRadioButtonThings to NoteDemonstration of JRadioButtonJComboBoxJListMultiple-Selection ListsMouse Event HandlingListener InterfacesSlide 38Adapter ClassesSlide 40Slide 41Extending MouseAdapter______________ MethodsKey Event HandlingLayout ManagersSlide 46FlowLayout___________LayoutGridLayoutPanelsCombining Components and GraphicsApplying ConceptsStep By StepAdd the Text LabelsAdd the Text BoxesFinal VersionImplement an Event HandlerGraphical User Interface Components: Part 1Chapter 112Graphical User Interface (GUI)•Gives program distinctive “____” and “_____”•Provides users with basic level of familiarity•Built from GUI components (controls, widgets, etc.)–User interacts with GUI component via _________, _____________, etc•Check out this visual index of components–http://java.sun.com/docs/books/tutorial/uiswing/ components/components.html3Netscape Window With GUI Componentsmenu barbutton combo boxmenusscroll bars4Some Basic GUI Components5Three Parts of a GUI Application1. ___________________ that make up the Graphical User Interface 2. Listeners that receive the events and ___________ to them 3. ______________ that does useful work for the user6Swing GUI Components•Package javax.swing•Components originate from AWT (package java.awt)•Contain look and feel–_______________ and how users ____________ with program•Lightweight components–Written completely in _____________7Overview of Swing Components•Class Component–Contains method _____ for drawing Component onscreen•Class Container–Collection of related components–Contains method _______ for adding components•Class ___________ (See Sun tutorial)–Pluggable look and feel for customizing look and feel–Shortcut keys (mnemonics)–Common _____________ capabilitiesObjectComponentContainerJComponent8Events Generated by Swing ComponentsAct that results in the event Listener type User clicks a button, presses Return while typing in a text field, or chooses a menu item ActionListener User closes a frame (main window) WindowListener User presses a mouse button while the cursor is over a component MouseListener User moves the mouse over a component MouseMotionListener Component becomes visible ComponentListener Component gets the keyboard focus FocusListener Table or list selection changes ListSelectionListener9Events Generated by Swing Components•Each event is represented by an ___________ –Object gives information about the event –Identifies the event _________. •Event sources are typically ____________, –Other kinds of objects can also be event sources. •Each event source can have ____________________ registered on it. –Conversely, a single listener can register with multiple event sources.10JLabel•Label–Provide ___________ on GUI–Defined with class JLabel–Can display:•Single line of_______________ text•Image•Text and _____________•View Figure 13.4 –Note uses of the JLabel Class11Event Handling•An event occurs every time the user–____________ a character or –Pushes a _________________•Any object can be ___________ of the event. •That object must:–_________________ the appropriate interface –Be registered as an _____________________ on the appropriate event source.12Event Handling•GUI's are event driven–Events occur when user ___________ with GUI–e.g., moving mouse, pressing button, typing in text field, etc.•Class java.awt.AWTEvent•Checkout Sun tutorial on event handling–http://java.sun.com/docs/books/tutorial/uiswing/ overview/event.html13Some Event Classes Of Package java.awt.eventObjectEventObjectAWTEventActionEventAdjustmentEventItemEventTextEventContainerEventFocusEventPaintEventWindowEventInputEventMouseWheelEventComponentEventKeyEvent MouseEventObjectEventObjectAWTEventComponentEventTextEventItemEventAdjustmentEventActionEventWindowEventInputEventMouseEventKeyEventMouseWheelEventFocusEventPaintEventContainerEvent14Event Handling Model•Three parts–Event _________________•GUI component with which user interacts–Event object•Encapsulates _____________________ that occurred–Event listener•___________ event object when notified, then _______•Programmer must perform two tasks–______________ event listener for event source–Implement event-handling method (event handler)15Event Listener Object •When a GUI program is running, each action of the user generates an event •The following are some types of events: –_____________ the mouse –Clicking the mouse on a _______________ –________________ into a text area •For a program to respond to an event there must be an _______________________ in the GUI program that listens to that type of event16What is an Event Listener?•An event listener is an . –It "listens" for events from a specific GUI component (itself an object) •When an event is generated by the GUI component–A method in the ______________ object is invoked to respond to the event17What If …?•When there is no event listener for an event –A program can _________________ events –If there is no listener for an event, the event is just ignored When a tree falls in the forest and there's no one present to hear it, does it make a sound?18Event-listener Interfaces Of Package java.awt.event interface EventListener interface ActionListener interface AdjustmentListener interface ComponentListener interface ContainerListener interface FocusListener interface ItemListener interface KeyListener interface MouseListener interface MouseMotionListener interface TextListener interface


View Full Document

LETU COSC 2103 - Graphical User Interface Components: Part 1

Documents in this Course
Arrays

Arrays

16 pages

Templates

Templates

17 pages

Methods

Methods

22 pages

Methods

Methods

22 pages

Arrays

Arrays

11 pages

Load more
Download Graphical User Interface Components: Part 1
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Graphical User Interface Components: Part 1 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Graphical User Interface Components: Part 1 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?