ptg7068951
WHAT YOU’LL LEARN IN
THIS HOUR:
.Scrolling components hori-
zontally and vertically
.Accepting a range of
numeric input with sliders
.Monitoring user input on
sliders
.Creating image icons and
toolbars
Creating a graphical user interface (GUI) with Swing involves more than
learning how to use the different interface components, layout managers,
and event-handling methods. You also have to familiarize yourself with
everything that Swing offers.
More than 400 different classes make Swing one of the most extensive class
libraries in Java. Many of these classes can be implemented using the same
techniques you have learned during the preceding three hours—Swing
containers and components share superclasses with each other, which
gives them common behavior.
During this hour, you learn about additional components that you can use
in your Swing programs.
Scroll Panes
Componentsin a GUI are often bigger than the area available to display
them. To move from one part of the component to another, vertical and
horizontal scrollbars are used.
In Swing, you offer scrolling by adding a component to a scroll pane, a
container that is represented by theJScrollPaneclass.
Yo u c a n c re a t e a s c ro l l p a n e w i t h t h e f o l l o w i n g c o n s t r u c t o r s :
. JScrollPane()—Create a scroll pane with a horizontal and vertical
scrollbar that appear as needed.
. JScrollPane(int, int)—Create a scroll pane with the specified
vertical scrollbar and horizontal scrollbars.
HOUR 16
Building a Complex User Interface