Set of Java Class Libraries provides as part of J2SE
Support building GUI and graphics functionality for Java based Client Application
Run on Microsoft Platform and others like Mac OSX and Linux
Easily deployed over the web
Rich clients for web services
Features of JFC
Abstract Windowing Toolkits
Swing GUI Components
Design pattern to Swing UI for JFC
Used for constructing entire UI Components
Each component has a Model, a View and a Controller.
The model, view ,and controller pieces can change even while the component is in use.
MVC Design Pattern Model Controller View Inform the view to update visual Read the contents Update the contents Inform view of state change
What MVC means?
Model is the piece that represents the state and low level behavior of the component.
(stored the data or stage of object)
View is the piece that manage the visual display of the state represented by the model
Controller is the piece that manages user interaction with the model.(handle the event)
Benefits using MVC
To divded large program to views of documents.
A view provides a window into document
Multiple views can provide multiple windows into the document.
AWT is the heave weight component and it has a peer object for the native GUI
When the components are created they take help of the underlying O/S
Java offers Light weight components that do not have a peer object.
It now popular by Swing UI components
Uses fewer system resources
Add a lot of more sophisticated components
Tailor the Look and Feel of program and
Extensing of Existing Components for
- Layout Management
- Event handling
- Thread and Swing
- Printing ….etc
Swing is set of packages build on top of the AWT with number of prebuild classes(over 250 classes and 40UI components)
All swing UI components are started with J for use the terms JFC and Swing interchangeabily
Structure of Swing Components JContainer Classes JComponent Classes All Swing Components
Sub Classes of the JComponent Class
JComponent is the superclass of all swing components. All the components begin with the letter ‘J’. JComponent has the following subclasses:
JButton & JLabel class
Swing Packages Swing Package Description javax.swing Contains components, adapters, component models and interfaces. It is the highest-level swing package. javax.swing.basic Contains the user interface classes that implement the look and feel for swing components. javax.swing.border Declares the border interface, and classes defining the specific border styles. javax.swing.plaf Contains the plugable look and feel API. javax.swing.table Contains the interfaces and classes supporting the swing table component. javax.swing.text Contains the support classes for the swing document framework. javax.swing.event Defines the events and event listeners. javax.swing.tree Provides classes and interfaces that support the JTree component. javax.swing.undo Provides support classes for undo/redo operations.
Swing Event Handling
For a Java program to run, the interface should be made receptive to user events
Swing handles events with a set of classes called ‘event listeners’
javax.swing.event package defines a set of event listening interfaces and event classes so that they can used with Swing components
There are various events defined in the javax.swing.event package, such as:
Look and Feel
Swing is a real improvement to the AWT, since it supplies rich set of platform GUI components
Platform independence means the components within it are supported across all Java ports
Enables the look and feel of the components to be easily tailored
This is called as Pluggable Look and Feel (L&F) of the swing components
This helps us to create applets and applications that have a look and feel independent to the window platform in which they are executed
Look and Feel Cont;
The look and feel consists of the way the program is presented to the user (looks) & the way user interacts with it (feels).
Swing provides the capability to change the look and feel of the applet or application.
Swing components are not tied to GUI components. It is because of this that we can create applets or applications that will use a specific look and feel. Look and feel is a function of view and controller.