HAPPY BOOKSGIVING
Use code BOOKSGIVING during checkout to save 40%-55% on books and eBooks. Shop now.
Register your product to gain access to bonus material or receive a coupon.
As the definitive reference to the Java 1.1.2 version class libraries from the creators of the Java technology at Sun, this book is an essential resource for both beginner and experienced Java programmers.
This volume provides comprehensive reference documentation for the development of applets, user interfaces, and Java beans. The information is presented in an easy-to-use, dictionary-like format. The packages covered in Volume 2 are:
java.applet | java.awt.image |
java.awt | java.awt.peer |
java.awt.datatransfer | java.beans |
java.awt.event |
The extensive class and member descriptions contain details crucial for developing robust and professional applets and applications. Each description is supplemented by an example that demonstrates the class or member in a relevant context. The 20,000 lines of code in over 350 examples facilitate learning-by-example and provide useful code fragments for your projects. Each class description includes:
Click below for Web Resources related to this title:
More Information from java.sun.com
Action Event.
Action Listener.
Active Event.
Adjustable.
Adjustment Event.
Adjustment Listener.
Applet.
Applet Context.
Applet Stub.
Area Averaging Scale Filter.
Audio Clip.
AWT Error.
AWT Event.
AWT Event Multicaster.
AWT Exception.
Bean Descriptor.
Bean Info.
Beans.
Border Layout.
Button.
Button Peer.
Canvas.
Canvas Peer.
Card Layout.
Checkbox.
Checkbox Group.
Checkbox Menu Item.
Checkbox Menu Item Peer.
Checkbox Peer.
Choice.
Choice Peer.
Clipboard.
Clipboard Owner.
Color.
Color Model.
Component.
Component Adapter.
Component Event.
Component Listener.
Component Peer.
Container.
Container Adapter.
Container Event.
Container Listener.
Container Peer.
Crop Image Filter.
Cursor.
Customizer.
Data Flavor.
Dialog.
Dialog Peer.
Dimension.
Direct Color Model.
Event.
Event Queue.
Event Set Descriptor.
Feature Descriptor.
File Dialog.
File Dialog Peer.
Filtered Image Source.
Flow Layout.
Focus Adapter.
Focus Event.
Focus Listener.
Font.
Font Peer.
Font Metrics.
Frame.
Frame Peer.
Graphics.
Grid Bag Constraints.
Grid Bag Layout.
Grid Layout.
Illegal Component State Exception.
Image.
Image Consumer.
Image Filter.
Image Observer.
Image Producer.
Index Color Model.
Indexed Property Descriptor.
Input Event.
Insets.
Introspection Exception.
Introspector.
Item Event.
Item Listener.
Item Selectable.
Key Adapter.
Key Event.
Key Listener.
Label.
Label Peer.
Layout Manager.
Layout Manager 2.
Lightweight Peer.
List.
List Peer.
Media Tracker.
Memory Image Source.
Menu.
Menu Bar.
Menu Bar Peer.
Menu Component.
Menu Component Peer.
Menu Container.
Menu Item.
Menu Item Peer.
Menu Peer.
Menu Shortcut.
Method Descriptor.
Mouse Adapter.
Mouse Event.
Mouse Listener.
Mouse Motion Adapter.
Mouse Motion Listener.
Paint Event.
Panel.
Panel Peer.
Parameter Descriptor.
Pixel Grabber.
Point.
Polygon.
Popup Menu.
Popup Menu Peer.
Print Graphics.
Print Job.
Property Change Event.
Property Change Listener.
Property Change Support.
Property Descriptor.
Property Editor.
Property Editor Manager.
Property Editor Support.
Property Veto Exception.
Rectangle.
Replicate Scale Filter.
RGB Image Filter.
Scrollbar.
Scrollbar Peer.
Scroll Pane.
Scroll Pane Peer.
Shape.
Simple Bean Info.
String Selection.
System Color.
Text Area.
Text Area Peer.
Text Component.
Text Component Peer.
Text Event.
Text Field.
Text Field Peer.
Text Listener.
Toolkit.
Transferable.
Unsupported Flavor Exception.
Vetoable Change Listener.
Vetoable Change Support.
Visibility.
Window.
Window Adapter.
Window Event.
Window Listener. 0201310031T04062001
This book is intended as a reference rather than a tutorial. Its format is similar to a dictionary's in that it is designed to optimize the time it takes for you to look up information on a class or class member. For a tutorial-style presentation of the class libraries, see The JavaTM Tutorial, by Mary Campione and Kathy Walrath. The JavaTM Class Libraries does not explain any part of the Java language. There are several books you can use to learn the language. These include The JavaTM Programming Language, by Ken Arnold and James Gosling, and The JavaTM Language Specification, by James Gosling, Bill Joy, and Guy Steele.
Following is an overview of this book.
This part briefly describes each package and all of the classes in it. Also included are diagrams that show the inheritance hierarchy of the classes that appear in a package.
This part covers the alphabetical listing of the classes from the following packages:
- java.applet
- java.awt
- java.awt.datatransfer
- java.awt.event
- java.awt.image
- java.awt.peer
- java.beans
Probably the most notable aspect about the structure of this book is the order in which the classes appear. Most Java books that contain an API alphabetically order the classes within a package and then alphabetically order the packages. The problem with this format is that it always takes two or more steps to locate a class. If you do not know which package contains the class you're looking for, you basically need to review each package looking for the class. If you do know which package, you first need to find the package and then find the class.
The classes in this book are ordered alphabetically without regard to package name. This makes looking up a class as straightforward as looking up a word in a dictionary.
Each class is described in its own chapter. Each chapter contains a picture of the class hierarchy, a class description, a class example, a member summary, and descriptions for every member in the class.
Class Hierarchy Diagrams
We include a class diagram for each class in the Java API. The class diagram shows all of the ancestors of the class, its siblings, its immediate descendents, and any interfaces that the class implements. In these diagrams, if a package name precedes a class or interface name, the class or interface is not in the same package as the current class.
In the diagrams, we visually distinguish the different kinds of Java entities, as follows:
Most of these elements are shown in Figure i. The class or interface being described in the current chapter is shaded grey. A solid line represents extends
, while a dotted line represents implements
.
Class Descriptions
In the class descriptions, we describe all of the properties of the class. For example, the properties of the Graphics
class include the current color, font, paint mode, origin, and clipping area. Describing in one place all of a class's available properties and how the properties behave makes learning all of the capabilities of a class much easier than if the property descriptions were scattered throughout the member descriptions.
Any terminology used in the member descriptions is introduced and described in the class descriptions. If you find that the member description lacks detail, go to the class description for more information.
Class Examples
Ideally, we would have included a unique example for every single member in the Java API. We simply did not have enough time. So we tried to make sure that every member appeared in at least one example.
We worked to make the examples as useful as possible so that they demonstrate the member as it would typically be used. For example, in the example for a button we not only show how a button is created; we also show how button events are handled. In some cases, we also try to demonstrate some other class in the Java API. For example, in the Graphics.draw-Oval()
example, we demonstrate not only how to draw an oval; we also show how to use the BufferedReader
class to read integers from standard input that are used to locate the oval. We feel that gently introducing other classes in the Java API is a good way to help you become aware of all available classes in the Java API, as long as the introduction does not confuse the example.
The Member Summary section for each class is intended to help the reader quickly grasp the key points of the class. It groups the members of the class into categories that are specific to that class. For example, in the List
class the Selection Methods category lists all methods having to do with selections. It is meant to be a quick summary of the class's members, so it does not contain any syntax information other than the name of the member.
The member descriptions appear in alphabetical order within a class chapter regardless of what kind of method or field they are. This was done to make locating a member proceed as fast as possible.
Overloaded methods are placed together in one member description because they share very similar functionality. The different overloaded forms are typically provided as a convenience for the programmer when specifying parameters. For instance, some overloads eliminate parameters by providing common defaults. To describe overloads with missing parameters, we use a phrase of the form "if the parameter p is not specified, it defaults to the value 3.14." Other overloads take different representations of a value. For example, one overload could take a particular parameter as an integer, while another could take the same parameter as a string containing an integer.
Each member description contains some or all of the following fields:
PURPOSE | A brief description of the purpose of this member | |
SYNTAX | The syntactic declaration of this member | |
DESCRIPTION | A full description of this member | |
PARAMETERS | The parameters accepted by this member, if any, listed in alphabetical order | |
RETURNS | The value and its range returned by this member, if any | |
EXCEPTIONS | The exceptions and errors thrown by this member, if any, listed in alphabetical order | |
SEE ALSO | Other related classes or members, if any, listed in alphabetical order | |
OVERRIDES | The method that this member overrides, if any | |
EXAMPLE | A code example that illustrates how this member is used. This is sometimes a reference to an example that illustrates the use of this method in another member example or class example. |
Deprecation
A method or class is deprecated if its use is no longer recommended. A deprecated method appears in the Member Summary under the Deprecated Methods section. In the chapter body, the deprecated method is annotated by a "deprecated" tag in its method heading. For example, Component.size() is a deprecated method. It has the following method heading:
size() | DEPRECATED | |
If not all of the overloaded forms of the method are deprecated, a "deprecated" tag appears beside the syntax of the deprecated forms. For example, one of the two forms of BorderLayout.addLayoutComponent()
is deprecated. The second form shown below--the one with the "deprecated" tag--is deprecated.
SYNTAX | public void addLayoutComponent(Component comp, Object location) | |
DEPRECATED | public void addLayoutComponent(String location, Component comp) |
The method description contains a deprecation section with instructions on how to replace the usage of the deprecated method, like this:
DEPRECATION A description of how to replace the usage of this deprecated method
All of the code examples in this book have been compiled and run on the FCS version of Java 1.1.2, either on Solaris or Windows NT or both. Most of the complete examples are available on-line. You can access them and other information about this book by using the URL
Lucida Sans Typewriter
is used for examples, syntax declarations, class names, method names, values, and field names. Italic is used when defining a new term and for emphasis.
We want to thank the many people who made this book possible.
We want to thank all of the wonderful readers of our first edition who sent us nice comments and suggestions. You gave us the strength to do this second edition.
Mike Hendrickson, the Acquisition Editor for this book, assisted us throughout the production of the book, from formatting the raw manuscript, to finding us experts to help with PostScript and formatting, to performing numerous coordination tasks. Thanks Mike!
Lisa Friendly, the series editor and a wonderful friend, was extremely helpful in providing all kinds of assistance in JavaSoft.
Sarah Weaver, Laura Michaels, Rosemary Simpson, Tracy Russ, Chris Norum, Jason Jones, and Yvo Riezebos all played a part in the production of this book and were wonderful to work with.
Tomas G. Rokicki provided invaluable expert advice (and code) so that we could generate all of the class diagrams automatically. Joseph Newcomer provided us with helpful hints for dealing with FrameMaker. And Ramin Sedehi rescued a week's worth of words after our laptop went south.
The following people provided many helpful comments and information: Calvin Austin, Tom Ball, Amy Fowler, Jim Graham, David Holmes, Doug Kramer, Tim Lindholm, Tim Prinzing, Georges Saab, and Kathy Walrath.
Roselyn and Norman Chin spent countless hours entertaining our children while we worked on the book.
Patrick Chan