Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Swing Mr. Crone. What is Swing? a collection of pre-made Java classes used to create a modern graphical user interface.

Similar presentations


Presentation on theme: "Introduction to Swing Mr. Crone. What is Swing? a collection of pre-made Java classes used to create a modern graphical user interface."— Presentation transcript:

1 Introduction to Swing Mr. Crone

2 What is Swing? a collection of pre-made Java classes used to create a modern graphical user interface

3 Swing Components Swing classes can be used to create the following: buttons text fields scroll bars check boxes radio buttons tables

4 Swing History Before Swing, Java had an original set of classes used for creating GUI’s This set of classes was known as AWT (Abstract Window Toolkit) The AWT was replaced by swing because of problems involving the use of GUI’s on different operating systems

5 Goal of Java Perhaps one of the main goals of the Java programming language was to be able to write code that could be used on any operating system The use of AWT created a conflict with this goal GUI’s created using AWT would look, or even act, different depending upon what operating system was used

6 The JFC JFC stands for Java Foundation Classes The JFC is a set of pre-made classes that can be used in project development Main parts of the JFC include: AWT Java 2D Drag and Drop Swing was added to the JFC in 1997 **Note: Swing did not replace AWT, but built upon its features

7 Components and Containers A swing GUI consists of two key items: Components Containers Component – an independent visual control such as a push button or slider Container – used to hold several components **Note: A container is really a component designed to hold other components

8 Components All component classes begin with the letter “J” Jframe Jlist JProgressBar JScrollBar JTextArea JToolBar Jmenu etc. All Swing components can be found within the javax.swing package

9 Containers Containers can contain other Containers Containers contain other containers can be listed in a hierarchy Top Level Containers: JFrame JApplet JWindow JDialog **As the name implies, top-level containers should be used at the top of the container hierarchy

10 Top-Level Containers A top-level container cannot be contained within any other container Every containment hierarchy must begin with a top-level container The most commonly used top-level container is JFrame The JApplet container is used in the creation of applets

11 Lightweight Containers Lightweight Containers can be placed in the container hierarchy below top-level containers Light weight containers are used to organize and manage groups of related components Examples: JPanel JRootPane Use lightweight containers to create subgroups of related controls

12 Panes Each top-level container defines a set of panes JRootPane is at the top of the pane hierarchy JRootPane is used to manage all other panes and is comprised of the following: Glass pane Content Pane Layered Pane **The content pane is the pane which you will add visual components to


Download ppt "Introduction to Swing Mr. Crone. What is Swing? a collection of pre-made Java classes used to create a modern graphical user interface."

Similar presentations


Ads by Google