Java Reference
In-Depth Information
For example, you might want your application to sound one or more beeps when a
can accomplish this task by specifying code that's similar to the following:
Toolkit toolkit = Toolkit.getDefaultToolkit();
for (int i = 0 ; i < 5; i++)
try { Thread.sleep(200); } catch (InterruptedException
ie) {}
Thisexamplerevealsthatyoumustobtaina Toolkit instancebeforeyoucancall
a Toolkit method, and that you do so by calling Toolkit 's Toolkit getDe-
faultToolkit() classmethod.Italsorevealsthatyoumightwanttoplaceasmall
delay between successive beeps to ensure that each beep is distinct.
Components, Containers, Layout Managers, and Events
and events.
A component is a graphical widget that appears in a window on the screen; a label,
known as a container .
A layout manager isanobjectthatorganizescomponentsandcontainerswithinacon-
An event isanobjectdescribingabuttonclickorotherGUIinteraction.Applications
register event listener objects with components to listen for specific events so that ap-
plication code can respond to them.
Components Overview
AWTprovidesawidevarietyofcomponentclassesinthe java.awt package. Figure
7-1 presents the class hierarchy for AWT's nonmenu component classes.
Search WWH ::

Custom Search