Presentation is loading. Please wait.

Presentation is loading. Please wait.

Provision for GUIs in Java

Similar presentations


Presentation on theme: "Provision for GUIs in Java"— 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 Swing 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).


Download ppt "Provision for GUIs in Java"

Similar presentations


Ads by Google