- Forward


Advanced GUI Layout
With Examples in Java


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu

Print

Hierarchical Template Layout
Back SMYC Forward
  • Overview:
    • Subdivide the sections in a template layout
  • Pros and Cons:
    • Platform independent and flexible
    • Difficult to get used to
Hierarchical Template Layout (cont.)
Back SMYC Forward

Using the (Almost) Composite Pattern

images/container-component.gif
Hierarchical Template Layout (cont.)
Back SMYC Forward

An Example

javaexamples/layout/HierarchicalLayoutDriver.java
 
Constrained Template Layout
Back SMYC Forward
  • The Idea:
    • Add constraints (e.g., doesn't expand) to sections of a template
  • In Java:
    • GridBagLayout java.awt.GridBagLayout
Constrained Template Layout (cont.)
Back SMYC Forward

An Example

javaexamples/gui/AboutDialog.java
 
Scrollable Components
Back SMYC Forward
  • The Idea:
    • Use a "viewport" to make only a portion of their total area visible at a time
    • Enable the visible portion to change (i.e., appear to scroll)
  • In Java:
    • The Scrollable javax.swing.Scrollable interface
    • A JScrollPane javax.swing.JScrollPane controls a Scrollable
Scrollable Components (cont.)
Back SMYC Forward
images/scrollpane.gif
Scrollable Components (cont.)
Back SMYC Forward

An Example

javaexamples/layout/ScrollableDriver.java
 
Docking Toolbars
Back SMYC Forward
  • The Concept:
    • A container that can be repositioned
  • In Java:
    • JToolBar javax.swing.JToolBar
Docking Toolbars (cont.)
Back SMYC Forward

Some Views

images/toolbar_windows.gif
images/toolbar_motif.gif
images/toolbar_java.gif
Docking Toolbars (cont.)
Back SMYC Forward

An Example

javaexamples/layout/DockDriver.java
 
Borders
Back SMYC Forward
  • Motivation:
    • Visually group components (e.g., a group of RadioButton java.awt.RadioButton objects)
  • In Java:
    • A Border javax.swing.Border can be applied to any JComponent javax.swing.JComponent
    • Because a large number are used they should be created using a BorderFactory javax.swing.BorderFactory
Border (cont.)
Back SMYC Forward

An Example

javaexamples/layout/BorderDriver.java
 
Layered Layout
Back SMYC Forward
  • Purpose:
    • Use the same "screen real estate" for multiple purposes
  • A Common Approach:
    • Put the different purposes on top of each other and provide a mechanism for moving between them
  • The Container:
    • JTabbedPane javax.swing.JTabbedPane
Layered Layout (cont.)
Back SMYC Forward

An Example

javaexamples/layout/JTabbedPaneDriver.java
 
There's Always More to Learn
Back -