Java Reference
In-Depth Information
Swing Components and Java Foundation Classes
Recall that Swing is a lightweight set of components that are a part of the Java
Foundation Classes (JFC). The JFC is defined as containing the features
summarized in Table 7-2.
Table 7-2
Features of the Java Foundation Classes (JFC)
FEATURE
DESCRIPTION
Swing Components
Swing components are implemented with no native code. Native refers to code
and components that are embedded in the operating system. Swing components,
therefore, may not appear identical to the components users are used to seeing in
their operating system. For example, a Windows message box looks different from a
JOptionPane message box because the Windows version uses the native common
dialog window. Swing components include everything from panels to buttons to
split panes to tables. Swing components begin with an uppercase J. You have used
JOptionPane Swing components in previous chapters.
Pluggable Look and
The look and feel methods offer any program using Swing a choice of how
Feel Support
windows, title bars, and other components will display. For example, the same
program can use either the Java look and feel or the Windows look and feel.
Accessibility API
This JFC API enables assistive technologies, such as screen readers and Braille
displays, to obtain information from the user interface.
Java 2D API
The 2D API enables programmers to incorporate high-quality 2D graphics, text, and
images in applications and applets.
Drag and Drop Support
First popularized by Microsoft Window applications, Java contains JFC methods to
provide drag and drop capabilities between a Java application and a native
application.
Swing Components versus AWT Components
Although the Java 2 Platform still supports the AWT components, it is
recommended that you use Swing components instead because they contain
more methods to manipulate and implement basic GUI-related features. Swing
components are not restricted to the least common denominator, or the features
present on every platform; therefore, they have more functionality than AWT
components. Even the simplest Swing components have capabilities beyond what
the AWT components offer.
The major difference between AWT components and Swing components is
that the latter are implemented with no native code. Therefore, Swing compo-
nents are backward compatible, which means they can be added on to older
versions of the JDK. Swing components are considered lightweight, which
means they borrow screen resources from the operating system and therefore do
not have to support their own. Heavyweight components, such as those used
with the AWT, are associated with their own native resource, or peer. Lightweight
components make more efficient use of their resources, provide consistency
across platforms, and have a cleaner look and feel integration. Recall that AWT
components are in the java.awt package, while Swing components are in the
javax.swing package.
 
Search WWH ::




Custom Search