Past Computing Environments: Swing

Download Report

Transcript Past Computing Environments: Swing

Past Computing Environments:
Swing
Ian Smith
UI Toolkits (History Lesson)
 Programming tools for building interfaces
 Originally in Java you had AWT
 AWT sucks
 AWT is based on “peers”
 JDK 1.0 (and 0.8, 0.9) shipped with AWT
Lots of cheers, lots of screams
UI Toolkits (History Continued)
 Backing away from AWT event model
 JDK 1.1 shipped with new event model
 Backing away from peers
 Several efforts underway to avoid peers
 Netscape offers IFC
 Different JVMs differ significantly
Simplified Timeline
 Early 1997, 100% Java UI work begins
Netscape & Sun join forces
 March 1997: Java One Demo & “Swing”
 Summer 1997: Swing 0.3 released
 Fall 1997: Versions fast an furious
 December 1997: API “Frozen”: Swing 0.7
 February 1998: Swing 1.0 release
What’s Swing (JFC?)
 Set of UI Components & MVC
 JDK 1.1 Event Model & Beans
 Pluggable Look & Feel
 Java 2D
 Compatible with AWT but in JDK 1.2
 Accessibility
 Drag And Drop
Questionable Graphic
Swing Components
 Swing is 250 classes, 75 interfaces
 The obvious (button, scrollbar, checkbox)
 MS competitors (combo box, internal
frame, split pane, tool bar, tool tip, etc)
 The monsters (text & table)
 A few choosers (file chooser, color chooser,
previewers)
Swing & MVC
 All components have an explicit model
 View & Controller are fused
 E.g. JAbstractButtonModel for Button,
RadioButton, CheckBox, etc.
 Linkage in both directions
 Apps can listen to the model
 Very sophisticated Document model
 Supercool for database applications
Swing Event Model (Beans)
 Everything is done with “listeners”
 E.g. “addActionListener()” to a JButton
 E.g. “addChangeListener()” to a
ButtonModel
 Simplifies linkage to application semantics
but stiffens event model
 All Swing objects are beans
 People are already using them in builders
Pluggable Look & Feel
 L&F is delegated to “separate” UI object
 L&F is pluggable & dynamic
 Organic, Windows, Motif (Mac? Mystery?)
 Windows only works on Windows
 Windows is pixel-accurate copy
Examples
Organic
Motif
Win32
Java 2D
 2D imaging model for Java (from adobe?)
 Seems very sophisticated
 All drawing in JDK 1.2 is done in terms of
Java 2D
 JDK 1.2 beta 2 is out, but Java 2D is very
slow and has broken font metrics
Compatible (?) with AWT...
 Generally, you can mix-n-match Swing with
AWT
 Some features work better in an all Swing
world
 When JDK 1.2 ships, Swing comes with
 JDK 1.2 beta 2 shipped with Swing 0.6
 Don’t use Swing with JDK 1.2 beta 2 if
possible
Accessibility
 Accessibility is part of JFC
 Accessibility is a bunch of interfaces
components can implement
 “Roles” “Actions” “AccessibleText”
 All Swing components are accessible
 Call your computer on a cell phone: you are
now blind
Drag And Drop
 JDK 1.2 will have drag and drop
 Interoperable with platform drag and drop
 Version 0.95 of D&D spec is out
 Swing plans to support D&D in JDK 1.2 (?)
 Spec is borderline impenetrable
Why To (Not) Use Swing
 + AWT is so broken as to be useless
 + It’s supported by Sun/Netscape; they care
 + Lots of output side power & flexibility
 + Source is available
 + Browser support (Activator)
 - Designed for “standard apps”
 - Not very flexible input
 - Still has AWT heritage