19-03-2014, 03:48 PM
Swing
Swing.pptx (Size: 467.88 KB / Downloads: 11)
What is Swing?
An API for Graphical User Interfaces (GUI)
set of classes that provides more powerful and flexible components than are possible with the AWT
Part of the Java Foundation Classes (JFC)
Provide a more sophisticated set of GUI components than the Abstract Windows Toolkit (AWT)
Implementing GUIs in Java
The Java Foundation Classes (JFC) are a set of packages encompassing the following APIs:
Abstract Window Toolkit (AWT): native GUI components
Swing: lightweight GUI components
2D: rendering two-dimensional shapes, text, and images
Accessibility: allowing compatibility with, for example, screen readers and screen magnifiers
[b]Abstract Window Toolkit (AWT)[/b]
Provides basic UI components:
Buttons, lists, menus, textfields, etc
Event handling mechanism
Clipboard and data transfer
Image manipulation
Font manipulation
Graphics
Platform independence is achieved through peers, or native GUI components
Peers and Platform Independence
The first AWT (Java 1.0) was rolled out in an incredible 6 weeks using peers
Thus an AWT menu on the Solaris platform, for example, actually creates a Motif menu object as its peer
UI components that have peers are called heavyweight because
they are rendered in their own (opaque) windows and thus are expensive to use,
they must be rectangular and cannot have transparent backgrounds, and
they are not amenable to being subclassed
AWT vs. Swing
Swing does not replace the AWT; it is built on top of it
AWT components are heavyweight; corresponding Swing components are lightweight
Swing component names begin with ``J'':
Component (AWT) vs. JComponent (Swing)
Button (AWT) vs. JButton (Swing)
Always use Swing components; however, since Swing is built on top of AWT, you will need to know some AWT methods
Swing components are available in javax.swing
Package.