Example Program - PowerPoint PPT Presentation

1 / 37
About This Presentation
Title:

Example Program

Description:

User input must be appropriate for the current state ... Keypad [Teal] - button button. 0 button = button. 7. 8. 9. 4. 5. 6. 0. 1. 2. 3. 93.54. ENT. Jan 23 ... – PowerPoint PPT presentation

Number of Views:26
Avg rating:3.0/5.0
Slides: 38
Provided by: vassilio
Category:
Tags: example | program | teal

less

Transcript and Presenter's Notes

Title: Example Program


1
Example Program
DemoKeyEvents2.java
2
Example Program
DemoMouseEvents.java
3
Example Program
DemoLowLevelEvents.java
DemoHighLevelEvents.java
4
Example Program
DemoActionEvents.java
DemoFocusEvents.java
5
Outline
  • Sequential programming
  • Event-driven programming
  • Modes

6
Coping With Complexity
  • How do we cope with complexity?
  • Typically, the interface is designed with modes
  • Each mode represents a different state of the
    system
  • User input must be appropriate for the current
    state
  • Moded systems require lots of variables to
    represent the state of the system

7
Examples of Modes
  • Draw programs
  • Use a mode to determine what is being drawn
  • E.g., line mode, rectangle mode, circle mode
  • Universal remote controls
  • E.g., TV mode, VCR mode
  • vi editor on Unix
  • Insert mode, command mode
  • Sport watches (Yikes! Too many modes!)

8
Example - MS PowerPoint
9
Modes in GUIs
  • One simple way is to use radio buttons

10
Example
DemoTranslateEnglishGUI2.java
11
Problems With Modes
  • Confusing if too many modes (the user has to
    remember the salient ones)
  • More modes make it easier for users to make
    errors (right command, wrong mode)
  • Need feedback as to current mode (vi doesnt, vim
    does).
  • Need a mechanism to switch modes
  • Modes do not scale well
  • Need a more advanced model to simplify windows
    programming

12
WIMP Elements
  • GUI goo

13
Outline
  • Windows
  • Icons
  • Pointers
  • Menus

14
Windows
  • Windows are areas of the screen that act like
    individual terminals for an application
  • Behaviour of windows determined by the systems
    window manager (aka windowing system)
  • Windows can contain text, graphics, menus,
    toolbars, etc.
  • Can be moved, resized, closed, minimized,
    maximized

15
Parts of a Window
focus (blue)
size control
title bar
menu bar
contents
scroll bar
size control
16
Layout Policy
  • Multiple windows may exist simultaneously
  • Physical arrangement determined by the window
    managers layout policy
  • Layout policy may be fixed or user-selectable
  • Possible layouts include
  • Overlapping - One window partially obscures
    another
  • Tiled - Adjoin but dont overlap
  • Cascading A sequence with each window offset
    from the preceding according to a rule (e.g., 10
    pixels to the right and below)
  • Lets see

17
Overlapping Windows
18
Tiled Windows
19
Cascading Windows
20
Focus
  • The active window is said to have focus
  • Title bar of active window is blue (or some other
    distinct colour)
  • Title bars of inactive windows are grey
  • Clicking in an inactive window makes it the
    active window (i.e., gives it focus)
  • Screen must be redrawn to bring the active window
    to the front

21
Window Size States
  • Windows have three size states
  • Maximized
  • Fills available space
  • Minimized
  • Reduced to a title bar or icon
  • Normal (aka Restored)
  • This is the size of the window, either when it
    was first opened, or before the window was
    maximized
  • From this mode, the window width and height may
    be adjusted

22
Window Size Control
  • Via boxes in upper-right corner of window
  • When maximized
  • When restored
  • When minimized

Minimize Restore Close
Minimize Maximize Close
Restore Maximize Close
23
Window Size Control (2)
  • Via handle in lower-right corner of window
  • When normal

Drag to resize
24
Window Size Control (3)
  • Via virtual handles on edges
  • When normal

Drag either edge to resize height
Drag either edge to resize width
25
Window Managers
  • User interfaces are typically implemented within
    the framework of a window manager
  • Also known as windowing system or user interface
    management system (UIMS)
  • Provides
  • Partitioning to prevent chaos on the screen (What
    if there was only one window shared by all
    applications?)
  • Layout Policy
  • Infrastructure to support common services in
    building UIs

26
Window Manager Structure
  • Base layer (implements the basic infrastructure)
  • Output model (graphics primitives)
  • Input model (keyboard, mouse)
  • UI layer (handles all visible aspects)
  • Presentation (e.g., what is on top?)
  • Commands (window content manipulation)
  • Mapping of input actions to applications
  • When building a UI, use services of windowing
    system where possible (rather than writing custom
    code)

27
Containment Hierarchy
  • A window is made up of a number of nested
    interactive objects (e.g.,buttons, text fields,
    other windows)
  • Relationship of objects is expressed by a
    containment hierarchy
  • based on screen geometry of objects
  • represents the hierarchy/nesting of the objects

28
Containment Hierarchy - Example 1
29
Containment Hierarchy - Example 2
Display Screen
Outer Win black
Inner Win green
Result Win tan
Result String
Keypad Teal
button
- button
button
0 button
30
Javas Containment Hierarchy
  • With JFC/Swing, the basic building block for a
    window is the JFrame and its associated panes

31
Javas Containment Hierarchy (2)
32
Containers
  • Components are placed in containers
  • A JFrame is a top-level container
  • It exists mainly as a place for other components
    to paint themselves
  • Other top-level containers are dialogs (JDialog)
    and applets (JApplet)
  • A JPanel is an intermediate container
  • Sole purpose is to simplify the positioning of
    interactive objects, such as buttons or text
    fields
  • Other intermediate containers are scroll panes
    (JScrollPane) and tabbed panes (JTabbedPane)

33
Atomic Components
  • An atomic component is a low-level,
    self-sufficient entity that interacts with the
    user
  • Examples buttons (JButton), text fields
    (JTextField), combo boxes (JComboBox)
  • JFrame and JPanel are also components, however
  • They can hold other components
  • An atomic component cannot hold other components

34
Containment Hierarchy for JFC/Swing
JFrame
content pane
Container
JPanel
JPanel
etc.
JButton
JLabel
etc.
JPanel
JButton
JTextField
35
So
JFrame content pane Container JPanel JPanel
Atomic component (text field) Atomic
component (buttons)
1.2345
36
Example Program
37
Containment Hierarchy (abbreviated)
DemoSwing.java
DemoSwingFrameframe0,0,0,224x208, ...
javax.swing.JRootPane,4,23,216x181, ...
javax.swing.JPanelnull.glassPane, ...
javax.swing.JLayeredPanenull.layeredPane,0,0,216x
181, ... javax.swing.JPanelnull.contentPane
,0,0,216x181, ... javax.swing.JPanel,0,0,
216x181, ... javax.swing.JButton,50,50,
116x27, ... javax.swing.JLabel,50,77,11
6x27, ... javax.swing.JButton,50,104,11
6x27, ...
Write a Comment
User Comments (0)
About PowerShow.com