Java GUI.ppt - GRAPHICAL USER INTERFACES GRAPHICAL USER...

This preview shows page 1 - 15 out of 49 pages.

GRAPHICAL USER INTERFACES
GRAPHICAL USER INTERFACE (GUI)User interfaceInterface between user and computerBoth input and outputAffects usability of computerInterface improving with better hardwareSwitches & light bulbsPunch cards & teletype (typewriter)Keyboard & black/white monitor (text)Mouse & color monitor (graphics)
GRAPHICAL USER INTERFACE (GUI)Design issuesEase of useEase of understandingAbility to convey informationMaintainabilityEfficiency
Computer ProgramGet input (keyboard, file, network, database)ProcessDeliver output (screen, file, network, database)Someprograms communicate directly with a "user"; there are two general user-interface approaches:Program-driven Paradigm>Enter number of dimes: 3>Enter number of nickels: 5>Enter number of pennies: 7>You have 62 centsThe programis in charge
User-driven ParadigmPresent the user interfaceWait for the user to do somethingThe useris in chargeReferred to as a GUI- Graphical User Interface
GRAPHIC USER INTERFACE OVERVIEWGUI elementsJava GUI classesEvent-driven programming
GUI Mechanics in JavaThe user’s action is called an event(key press, mouse click, double-click, typing, etc.)The component receiving the event generates a software event objectIt passes the software event object to its registered listeners, by invoking the method defined in the listenerinterfaceThe listeners do something appropriate in response to the event
TWO WAYS TO PRESENT THE GRAPHICAL USER INTERFACEAdd standard Components (Buttons, TextFields, etc.)Only Components can receive eventsComponents must be added to ContainersAppletis a ContainerModify the paint()method
GUI ELEMENTSComponentitems displayed (widgets)Container region containing widgets Layoutarrangement of containerEvent interactions for GUI
Background image
GUI ELEMENTS – COMPONENTDefinitionActual items (widgets) user sees in GUIExamplesLabels (fixed text)Text areas (for entering text)ButtonsCheckboxesTablesMenusToolbarsEtc…
CONTAINERSEvery element of a UI must be a ComponentDefinitionAbstractions occupying space in GUIPropertiesUsually contain one or more widgetsCan be nested in other containersA Containeris a Component which may hold other Components, including other ContainersComponents are added to Containers using Container’s add()methodNote that all overloads of the add()method require a ComponentparameterExampleWindow containing1 menu (component) 3 buttons (component)2 windows (container)
ComponentContainerJComponentOther SwingComponentsWindowPanelFrameDialogAppletJPanelJFrameJDialogJAppletUI Component HierarchyButtonLabelListetc.
GUI ELEMENTS – LAYOUTDefinitionArrangement of widgets in containerLayout specificationLogical terms (2ndrow, 1stcolumn, left)Preferred approachActual coordinates (100 pixels, 5 inches)Can be too rigid, limited to certain window sizes Layout managerEntity translating layout specifications into actual coordinates at runtime, depending on conditions

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture