Presentation is loading. Please wait.

Presentation is loading. Please wait.

Swing & the JFC – Advanced Java GUI

Similar presentations


Presentation on theme: "Swing & the JFC – Advanced Java GUI"— Presentation transcript:

1 Swing & the JFC – Advanced Java GUI
Lecture 29 Swing & the JFC – Advanced Java GUI

2 Java Foundation Classes (JFC)
JFC consists of five API AWT Java 2D Java Accessibility Java Drag & Drop Swing

3 Versions Java AWT 1.0, but no Swing (NB AWT 1.0 incompatible with Swing) Java AWT 1.1, Swing as an add-on Java 2 - Swing is core Java 1.2 / 1.3 / 1.4 / 1.5 Be particularly careful with applets – Swing will only work if a Java2 VM is present in the browser

4 What is Swing? Swing is a component library
Based upon AWT 1.1 widgets and event model AWT extended by JComponents and supporting classes Analagous classes to AWT (mostly extended) New classes

5 Swing vs AWT Much larger than AWT No native code
Most components (eg buttons, labels, lists etc) can display images as well as text Text formatting allowed (HTML) Better border control Components do not have to be rectangular

6 Limitations of Swing Large API
Be careful with mixing Swing with “heavyweight” non-Swing components. Swing components are not “thread safe” Swing components must be in a Swing container

7 Swing Packages javax.swing javax.swing.border javax.swing.text
javax.swing.colorchooser javax.swing.event javax.swing.filechooser javax.swing.plaf javax.swing.table javax.swing.text javax.swing.text.html javax.swing.text.rtf javax.swing.tree javax.swing.undo javax.accessibility

8 Content Panes Swing containers are much more complex than AWT
All containers have “panes”, to which components are added These are loosly similar to AWT panels, but have many other properties

9 Plugable User Interfaces
plaf - Plugable Look & Feel Cross-platform look & feel (Metal) Motif OS Specific (eg Windows, Macintosh etc) Customised look & feel

10 Converting AWT to Swing
Import main Swing package (import javax.swing) Check threading issues (only modify components with their own methods) Replace all AWT components with Swing equivalents Modify methods as necessary Change calls to add() and setLayout() methods to use panes of containers


Download ppt "Swing & the JFC – Advanced Java GUI"

Similar presentations


Ads by Google