Java Reference
In-Depth Information
JWindow
A top-level window that has no border. (934)
layout manager
A helper object that automatically arranges components of a
container. (941)
listener adapter class
Provides default implementations for a listener interface
that has more than one method. (950)
null
layout
A layout used to perform precise positioning. (944)
pack
A method used to pack a
JFrame
into its smallest size given its constituent
components. (948)
paintComponent
A method used to draw onto a component. Typically overrid-
den by classes that extend
JPanel
. (945)
repaint
A method used to clear and repaint a component. (945)
setLayout
A method that associates a layout with a container. (941)
show
A method that makes a component visible. (948)
WindowAdapter
A class that provides default implementations of the
WindowListener
interface. (950)
WindowListener
interface
An interface used to specify the handling of window
events, such as window closing. (948)
1.
Forgetting to set a layout manager is a common mistake. If you forget it,
you'll get a default. However, it may not be the one you want.
2.
The layout manager must appear prior to the calls to
add
.
3.
Applying
add
or setting a layout manager to the wrong container is a com-
mon mistake. For instance, in a container that contains panels, applying
the
add
method without specifying the panel means that the
add
is applied
to the main container.
A missing
String
argument to
add
for
BorderLayout
uses
"Center"
as the
default. A common mistake is to specify it in the wrong case, as in
"north"
. The five valid arguments are
"North"
,
"South"
,
"East"
, "
West"
, and
"Center"
. In Java 1.1, if the
String
is the second parameter, a run-time
exception will catch the error. If you use the old style, in which the
String
comes first, the error might not be detected.
4.
Special code is needed to process the window-closing event.
5.
Search WWH ::
Custom Search