1 / 13

Provision for GUIs in Java

Provision for GUIs in Java. CSC 202. Evolution of GUI Capabilities in Java. Java 1.0 Abstract Window Toolkit (AWT). Called “Abominable” or “Awful Window Toolkit”. Done in 30 days. Last minute add-on. Java 1.1 Significantly improved, But GUI not finished. Java 2 - Swing.

uta-boyle
Download Presentation

Provision for GUIs in Java

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. Provision for GUIs in Java CSC 202

  2. Evolution of GUI Capabilities in Java

  3. Java 1.0 Abstract Window Toolkit (AWT) • Called “Abominable” or “Awful Window Toolkit”. • Done in 30 days. • Last minute add-on. • Java 1.1 • Significantly improved, • But GUI not finished.

  4. Java 2 - Swing • Much improved from AWT. • Part of Java Foundation Classes (JFC). • Very easy to add: • Accelerators • Tool Tips • Graphics • Pluggable look and feel.

  5. AWT vs Swing • AWT approach • Implement common elements of various operating environments. • Swing approach • Departure from AWT effort. • Swing only needs to know how to write a pixel on a screen in a particular environment. • AWT classes are extended in Swing. • Example: AWT Button became Swing JButton.

  6. The Operating System GUI Interface

  7. Multitask operating system(Windows, UNIX, Linux, etc.) • When the o.s. detects an event such as a mouse click, • It determines what the event was; • It determines in which application window it occurred.

  8. Operating System Interface • The operating system • Passes event info as a message to the appropriate application, and • Permits the app to take action. • May interrupt the subsequent action if another event is detected.

  9. Containment Hierarchy - 1 • One and only one top-level container. • May contain any number of intermediate-level and atomic components. • Swing: almost always a JFrame. • Automatically provides a root pane. • AWT: the top-level container was referred to as “heavyweight” component. • “Weighed down” with responsibility of interacting with the O/S. • “Lightweight” components are not tied to the O/S.

  10. Containment Hierarchy - 2 • Next important level: “content pane.” • Internal component of the top-level container. • All visible components other than menu bar go here. (See h/o, Bronson, 571).

  11. Containment Hierarchy - 3 • Lower levels (“lightweight components”): • Atomic components. • Intermediate components.

  12. Layout Managers • Each top-level and intermediate container has a default layout manager. • JFrame, JDialog, and JPanel – BorderLayout • JWindow – FlowLayout • Defines how components are sized and positioned within the container's content pane. (See handout - Bronson, 605.)

  13. Creating a Swing-Based Window - Two Approaches: • Construct a GUI object using Swing components from within a main() method without first creating a separate GUI class. Sometimes used to introduce Swing components and to create extremely simple GUIs. This is how our first example was done. (See FirstGUI.java) • Construct the GUI as a separate class using Swing components. (See FirstWindow.java) • In general this is preferred (adheres more closely to accepted OO practice).

More Related