Swing components & MVC Architecture

13
Swing Components 1. What are Swing Components 2. Top Level Containers 3. General Purpose Containers 4. Basic Controls 5. Uneditable Information Displays 6. Interactive Displays of Highly Formatted Information

Transcript of Swing components & MVC Architecture

Page 1: Swing components & MVC Architecture

Swing Components1. What are Swing Components

2. Top Level Containers

3. General Purpose Containers

4. Basic Controls

5. Uneditable Information Displays

6. Interactive Displays of Highly Formatted Information

Page 2: Swing components & MVC Architecture

* Swing components are basic building blocks of an application. * Swing has a wide range of various components, including buttons, check boxes, sliders, and list boxes.

1. What are Swing Components

Page 3: Swing components & MVC Architecture

1. Top Level Containers* Every program with a Swing GUI must contain at least one top-level Swing

container that provides the support that Swing components need to perform their painting and event handling.

* Swing provides three generally useful top-level container classes:

1. JFrame 2. JDialog 3. JApplet.

* Each JFrame object implements a single main window, and each JDialog implements a secondary window (a window that's dependent on another window). Each JApplet object implements an applet's display area within a browser window.

Page 4: Swing components & MVC Architecture

When using these classes, you should keep these facts in mind:

• To appear onscreen, every GUI component must be part of a containment hierarchy. Each containment hierarchy has a top-level container as its root.

• Each top-level container has a content pane that, generally speaking, contains the visible components in that top-level container's GUI.

• You can optionally add a menu bar to a top-level container. The menu bar is positioned within the top-level container, but outside the content pane.

Page 5: Swing components & MVC Architecture

Here's a picture of a frame created by an application. The frame contains a green menu bar (with no menus) and, in the frame's content pane, a large blank, yellow label.

Page 6: Swing components & MVC Architecture

• The SourceOf previous example

Page 7: Swing components & MVC Architecture

2. General Purpose Containers

Page 8: Swing components & MVC Architecture

1. Typically used to collect Basic Controls (JButton, JChoiceBox…)

2. Added to layout of top-level containers

JPanel

JFrame

Page 9: Swing components & MVC Architecture

3. Basic Controls

Page 10: Swing components & MVC Architecture

4. Uneditable Information Displays

Page 11: Swing components & MVC Architecture

5. Interactive Displays of Highly Formatted Information

Page 12: Swing components & MVC Architecture

MVC Architecture

Page 13: Swing components & MVC Architecture