Register your product to gain access to bonus material or receive a coupon.
The popularization of the World Wide Web has catapulted the Java language into the limelight. Java is a general-purpose, object-oriented language that was designed to be robust, secure, and to run on a variety of machines and operating systems. Like HTML pages, compiled Java programs are network- and platform-independent. With Java as an extension language, Web browsers can have almost unlimited capabilities.
The Java Application Programming Interface describes the libraries that every programmer can use to write Java applications and applets. These two volumes were written by the development team that created the Java API. They are authoritative, accurate, comprehensive, and completely up to date.
Volume 1: Core Packages describes the libraries that are the foundation of the Java language. These libraries include java.lang, java.io. java.util, and java.net. These are the general-purpose libraries fundamental to every Java program.
Volume 2: Window Toolkit and Applets describes the libraries that you can use to create sophisticated and visually appealing Java applications and applets. In addition, this volume illustrates how you can create embedded programs that can be transported safely across the network. These libraries include java.awt, java.awt.image, java.awt.peer, and java.applet.
Every Java programmer who wants to create secure, efficient, portable, and robust applications should have a thorough knowledge of the Java API.
0201634538B04062001
VOLUME I.
Preface.A Bit of History.
About The Java Series.
Contributors to the API.
About the Java Packages.
References.
Class Hierarchy Diagrams.Classes.
Class Boolean.
Class Character.
Class Class.
Class ClassLoader.
Class Compiler.
Class Double.
Class Float.
Class Integer.
Class Long.
Class Math.
Class Number.
Class Object.
Class Process.
Class Runtime.
Class SecurityManager.
Class String.
Class StringBuffer.
Class System.
Class Thread.
Class ThreadGroup.
Class Throwable.
Interfaces.
Interface Cloneable.
Interface Runnable.
Exceptions.
Class ArithmeticException.
Class ArrayIndexOutOfBoundsException.
Class ArrayStoreException.
Class ClassCastException.
Class ClassNotFoundException.
Class CloneNotSupportedException.
Class Exception.
Class IllegalAccessException.
Class IllegalArgumentException.
Class IllegalMonitorStateException.
Class IllegalThreadStateException.
Class IndexOutOfBoundsException.
Class InstantiationException.
Class InterruptedException.
Class NegativeArraySizeException.
Class NoSuchMethodException.
Class NullPointerException.
Class NumberFormatException.
Class RuntimeException.
Class SecurityException.
Class StringIndexOutOfBoundsException.
Errors.
Class AbstractMethodError.
Class ClassCircularityError.
Class ClassFormatError.
Class Error.
Class IllegalAccessError.
Class IncompatibleClassChangeError.
Class InstantiationError.
Class InternalError.
Class LinkageError.
Class NoClassDefFoundError.
Class NoSuchFieldError.
Class NoSuchMethodError.
Class OutOfMemoryError.
Class StackOverflowError.
Class ThreadDeath.
Class UnknownError.
Class UnsatisfiedLinkError.
Class VerifyError.
Class VirtualMachineError.
Package java.io.Classes.
Class BufferedInputStream.
Class BufferedOutputStream.
Class ByteArrayInputStream.
Class ByteArrayOutputStream.
Class DataInputStream.
Class DataOutputStream.
Class File.
Class FileDescriptor.
Class FileInputStream.
Class FileOutputStream.
Class FilterInputStream.
Class FilterOutputStream.
Class InputStream.
Class LineNumberInputStream.
Class OutputStream.
Class PipedInputStream.
Class PipedOutputStream.
Class PrintStream.
Class PushbackInputStream.
Class RandomAccessFile.
Class SequenceInputStream.
Class StreamTokenizer.
Class StringBufferInputStream.
Interfaces.
Interface DataInput.
Interface DataOutput.
Interface FilenameFilter.
Exceptions.
Class EOFException.
Class FileNotFoundException.
Class IOException.
Class InterruptedIOException.
Class UTFDataFormatException.
Package java.util.Classes.
Class BitSet.
Class Date.
Class Dictionary.
Class Hashtable.
Class Observable.
Class Properties.
Class Random.
Class Stack.
Class StringTokenizer.
Class Vector.
Interfaces.
Interface Enumeration.
Interface Observer.
Exceptions.
Class EmptyStackException.
Class NoSuchElementException.
Package java.net.Classes.
Class ContentHandler.
Class DatagramPacket.
Class DatagramSocket.
Class InetAddress.
Class ServerSocket.
Class Socket.
Class SocketImpl.
Class URL.
Class URLConnection.
Class URLEncoder.
Class URLStreamHandler.
Interfaces.
Interface ContentHandlerFactory.
Interface SocketImplFactory.
Interface URLStreamHandlerFactory.
Exceptions.
Class MalformedURLException.
Class ProtocolException.
Class SocketException.
Class UnknownHostException.
Class UnknownServiceException.
Index.
VOLUME II.
Preface.A Bit of History.
About The Java Series.
Contributors to the API.
About the Java Packages.
References.
Class Hierarchy Diagrams.Classes.
Class BorderLayout.
Class Button.
Class Canvas.
Class CardLayout.
Class Checkbox.
Class CheckboxGroup.
Class CheckboxMenuItem.
Class Choice.
Class Color.
Class Component.
Class Container.
Class Dialog.
Class Dimension.
Class Event.
Class FileDialog.
Class FlowLayout.
Class Font.
Class FontMetrics.
Class Frame.
Class Graphics.
Class GridBagConstraints.
Class GridBagLayout.
Class GridLayout.
Class Image.
Class Insets.
Class Label.
Class List.
Class MediaTracker.
Class Menu.
Class MenuBar.
Class MenuComponent.
Class MenuItem.
Class Panel.
Class Point.
Class Polygon.
Class Rectangle.
Class Scrollbar.
Class TextArea.
Class TextComponent.
Class TextField.
Class Toolkit.
Class Window.
Interfaces.
Interface LayoutManager.
Interface MenuContainer.
Exceptions.
Class AWTException.
Errors.
Class AWTError.
Package java.awt.image.Classes.
Class ColorModel.
Class CropImageFilter.
Class DirectColorModel.
Class FilteredImageSource.
Class ImageFilter.
Class IndexColorModel.
Class MemoryImageSource.
Class PixelGrabber.
Class RGBImageFilter.
Interfaces.
Interface ImageConsumer.
Interface ImageObserver.
Interface ImageProducer.
Package java.awt.peer.Interfaces.
Interface ButtonPeer.
Interface CanvasPeer.
Interface CheckboxMenuItemPeer.
Interface CheckboxPeer.
Interface ChoicePeer.
Interface ComponentPeer.
Interface ContainerPeer.
Interface DialogPeer.
Interface FileDialogPeer.
Interface FramePeer.
Interface LabelPeer.
Interface ListPeer.
Interface MenuBarPeer.
Interface MenuComponentPeer.
Interface MenuItemPeer.
Interface MenuPeer.
Interface PanelPeer.
Interface ScrollbarPeer.
Interface TextAreaPeer.
Interface TextComponentPeer.
Interface TextFieldPeer.
Interface WindowPeer.
Package java.applet.Classes.
Class Applet.
Interfaces.
Interface AppletContext.
Interface AppletStub.
Interface AudioClip.
Index. 0201634538T04062001
The popularization of the World Wide Web helped catapult these attributes of Java into the limelight. The Internet demonstrated how interesting, media-rich content could be made accessible in simple ways. Web browsers like Mosaic enabled millions of people to roam the Net and made Web surfing part of popular culture. At last there was a medium where what you saw and heard was essentially the same whether you were using a Mac, PC, or UNIX machine, connected to a high-speed network or a modem.
With popularity comes scrutiny, however, and soon Web enthusiasts felt that the content supported by the Web's HTML document format was too limited. HTML extensions, such as forms, only highlighted those limitations while making it clear that no browser could include all the features users wanted. Extensibility was the answer. At just this time the Java programming language found itself looking for another application.
Sun's HotJava browser was developed to showcase Java's interesting properties by making it possible to embed Java programs inside Web pages. These Java programs, known as applets, are transparently downloaded into the HotJava browser along with the HTML pages in which they appear. Before being accepted by the browser, applets are carefully checked to make sure they are safe. Like HTML pages, compiled Java programs are network- and platform-independent. Applets behave the same regardless of where they come from or what kind of machine they are being loaded into.
The Web community quickly noticed that Java was something new and important. With Java as the extension language, a Web browser could have limitless capabilities. Programmers could write an applet once and it would then run on any machine, anywhere. Visitors to Java-powered Web pages could use the content found there with confidence that nothing would damage their machine.
With applets as the initial focus, Java has demonstrated a new way to make use of the Internet to distribute software. This new paradigm goes beyond browsers. We believe it is an innovation with the potential to change the course of computing.
Tim Lindholm
Senior Staff Engineer
JavaSoft
April 1996
To learn the latest about Java or to download the latest Java release, visit our World Wide Web site at http://java.sun.com
. For updated information about The Java Series, including sample code, errata, and previews of forthcoming books, visit http://java.sun.com/books/Series
.
We would like to thank the Corporate and Professional Publishing Group at Addison-Wesley for their partnership in putting together the Series. Our editor, Mike Hendrickson, and his team have done a superb job of navigating us through the world of publishing. The support of James Gosling, Ruth Hennigar, and Bill Joy of Sun Microsystems ensured that this series would have the resources it needed to be successful. A personal note of thanks to my children, Christopher and James, for putting a positive spin on the many trips to my office during the development of the Series.
Lisa Friendly
Series Editor
Although the API has not reached perfection yet, we believe it is useful and hope to make it a ubiquitous layer, available to all Internet applications.
Have fun.
Arthur van Hoff
The extent of the API and the choice of functionality have been driven by several factors. First and foremost, the API should be simple and easy to use. Parts of the API, such as the support for multithreading, might introduce functionality that is new to you, but we think you will find these new concepts simpler and easier to use than in most other programming environments.
The libraries in these books are the first generation of an API for writing Internet programs. A simple form of an Internet program is an applet-a small Java program that can be embedded in an HTML page.
The API has been designed with the Java language in mind. Important Java features such as object orientation, garbage collection, and multithreading played an important role in the API design. Instead of taking existing libraries and simply rewriting them in Java, we designed and implemented the API with full use of the Java language.
For Java 1.0, we have tried to stay away from certain complex functionality, such as video and 3D, so that library implementations can be ported easily. We can include only functionality that is not proprietary and that is easily implemented on many platforms.
We expect to add to the API, but not to subtract from it or change its behavior. The API documented in this book will remain available to all Java programs through future releases.
If you have ideas about how the API could be improved or how to implement some of the missing functionality, we would like to hear from you. Please send your ideas and implementations to java@java.sun.com
.
As you design and implement Java programs, you should write short test programs to verify your understanding of the classes. When in doubt, try it out!
The Java web site, http://java.sun.com/
, contains many excellent and sometimes interactive explanations that can help you along. Another good source of information is the newsgroup comp.lang.java
.
java.lang
) and ending with one of the most specialized packages (java.applet
). Each package groups classes and interfaces that have similar functionality. The API contains the following packages:Volume I: Core Packages
java.lang
: The Java Language Packagejava.io
: The Java I/O Packagejava.util
: The Java Utility Packagejava.net
: The Java Networking Packagejava.awt
: The Abstract Window Toolkit (AWT) Packagejava.awt.image
: The AWT Image Packagejava.awt.peer
: The AWT Peer Packagejava.applet
: The Java Applet Packagejava.lang
: The Java Language Packagejava.lang
package provides the classes and interfaces that form the core of the Java language and the Java Virtual Machine. For example, the classes Object
, String
, and Thread
are used by almost every program and are closely intertwined with the Java language definition. Other java.lang
classes define the exceptions and errors that the Java Virtual Machine can throw.Another set of java.lang
classes provide wrappers for primitive types. For example, the Integer
class provides objects to contain int
values.
Still other classes, such as ClassLoader
, Process
, Runtime
, Security-Manager
, and System
, provide access to system resources. For other generally useful classes, see the java.util
package.
The java.lang
package is imported automatically into every Java program.
java.io
: The Java I/O Packagejava.io
package provides a set of input and output (I/O) streams used to read and write data to files or other I/O sources. Java streams are byte oriented and the classes defined here can be chained to implement more sophisticated stream functionality.java.util
: The Java Utility Packagejava.util
package contains a collection of utility classes and related interfaces. It includes classes that provide generic data structures (Dictionary
, Hashtable
, Stack
, Vector
), string manipulation (StringTokenizer
), and calendar and date utilities (Date
).The java.util
package also contains the Observer
interface and Observable
class, which allow objects to notify one another when they change.
java.net
: The Java Networking Packagejava.net
package contains networking classes and interfaces, including classes that represent a URL and a URL connection, classes that implement a socket connection, and a class that represents an Internet address.java.awt
: The Abstract Window Toolkit (AWT) Packagejava.awt
package provides the standard graphical user interface (GUI) elements such as buttons, lists, menus, and text areas. It also includes containers (such as windows and menu bars) and higher-level components (such as dialogs for opening and saving files). The AWT contains two more packages: java.awt.image
and java.awt.peer
.java.awt.image
: The AWT Image Packagejava.awt.image
package contains classes and interfaces for performing sophisticated image processing. These classes and interfaces can be used by applications that need to create or manipulate images and colors.java.awt.peer
: The AWT Peer Packagejava.awt.peer
package contains interfaces used to connect AWT components to their window system-specific implementations (such as Motif widgets). Unless you are creating a window system-specific implementation of the AWT, you should not need to use the interfaces in the java.awt.peer
package.
java.applet
: The Applet Packagejava.applet
package contains classes and interfaces for creating applets.The Unicode Standard: Worldwide Character Encoding, Version 1.0, Volume 1 ISBN 0-201-56788-1 and Volume 2 ISBN 0-201-60845-6. Additional information about Unicode 1.1 may be found at ftp://unicode.org
.
0201634538P04062001