1 / 10

Lecture 29

Lecture 29. Swing & the JFC – Advanced Java GUI. Java Foundation Classes (JFC). JFC consists of five API AWT Java 2D Java Accessibility Java Drag & Drop Swing. Versions. Java 1.0 - AWT 1.0, but no Swing (NB AWT 1.0 incompatible with Swing)

leal
Télécharger la présentation

Lecture 29

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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 1.0 - AWT 1.0, but no Swing (NB AWT 1.0 incompatible with Swing) • Java 1.1 - 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. javax.swing javax.swing.border 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 Swing Packages

  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

More Related