Java Reference
In-Depth Information
Q&A
Q Can an application be created without Swing?
A Certainly. Swing is just an expansion on the Abstract Windowing Toolkit, and if
you are developing an applet for older versions of Java, you could use only AWT
classes to design your interface and receive input from a user. However, there's no
comparison between Swing's capabilities and those offered by the AWT. With
Swing, you can use many more components, control them in more sophisticated
ways, and count on better performance and more reliability.
Other user interface libraries also extend or compete with Swing. One of the most
popular is the Standard Widget Toolkit (SWT), an open source graphical user inter-
face library created by the Eclipse project. The SWT offers components that appear
and behave like the interface components offered by each operating system. For
more information, visit the website http://www.eclipse.org/swt.
Q In the Slider application, what does the pack() statement do?
A Every interface component has a preferred size, although this is often disregarded
by the layout manager used to arrange the component within a container. Calling a
frame or window's pack() method causes it to be resized to fit the preferred size of
the components that it contains. Because the Slider application does not set a size
for the frame, calling pack() sets it to an adequate size before the frame is dis-
played.
Q When I try to create a tabbed pane, all that displays are the tabs—the panels
themselves are not visible. What can I do to correct this?
A Tabbed panes won't work correctly until the contents of those panes have been
fully set up. If a tab's panes are empty, nothing will be displayed below or beside
the tabs. Make sure that the panels you are putting into the tabs are displaying all
their components.
10
Quiz
Review today's material by taking this three-question quiz.
Questions
1. What is the default look and feel in a Java application?
a. Motif
b. Windows
c. Metal
 
 
Search WWH ::




Custom Search