|
|
By David Flanagan
2nd Edition May 1997
Series: In a
Nutshell
ISBN: 1-56592-262-X
This second edition of the bestselling Java book describes all the classes in the Java 1.1 API, with the exception of the Enterprise APIs. And it still has all the great features that have made this the Java book most often recommended on the Internet: practical real-world examples and compact reference information. It's the only quick reference you'll need. [Full Description]
Download the code examples from this book. The complete set of examples is available at: http://examples.oreilly.com/javanut2/
The Java programming examples linked below are from the book Java in a Nutshell, Second Edition, by David Flanagan, published by O'Reilly & Associates.
If you are looking for the examples from the *first* edition of Java in a Nutshell, click here.
Although you can view the example source code online, by following the links below, I recommend that you download the complete set of examples so that you can work with them on your computer locally. They are available as a zip file or as a gzipped tar file.
If you find any bugs in these examples, please send e-mail describing the bug to bookquestions@ora.com. If you have found a workaround to the problem, please include it.
The examples were written by David Flanagan, and are Copyright (c) 1997 by O'Reilly and Associates.
You may study, use, and modify these examples for any purpose. This means that you can use the examples, or modified versions of the examples in your programs, and you can even sell those programs. You can distribute the source code to these examples, but only for non-commercial purposes, and only as long as the copyright notice is retained. This means that you can make them available on a public Web site, for example, but that you cannot include them on a commercial CD-ROM without the prior permission of O'Reilly and Associates.
Note that these examples are provided AS-IS, with absolutely NO WARRANTY of any kind, either expressed or implied.
Scribble.java: an applet of intermediate complexity, used as an example in the introductory chapter.
throwtest.java: an application that demonstrates how to define, throw, and handle exceptions. This application doesn't do anything other than print out some text, but you might want to study it and play around with it to learn more about how exceptions work in Java. See the usage instructions in the source code.
FirstApplet.java: the simplest possible applet. Displays "Hello World"
SecondApplet.java: a fancier version of "Hello World"
Scribble.java: a simple applet with user interaction. It allows the user to click and scribble in the window.
ColorScribble.java: the scribble applet, with colors specified through applet parameters in an HTML file.
Soundmap.java: An applet that displays an image, plays a sound, and demonstrates several other applet capabilities.
Scribble1.java: a simple applet, using the Java 1.0 event model.
Scribble2.java: the same applet, using the Java 1.1 event model.
Scribble3.java: the applet using the Java 1.1 event model and inner classes.
Scribble4.java: the applet using a low-level interface to the Java 1.1 event model.
ScribbleFrame.java: a relatively long application that demonstrates many of the new AWT features of Java 1.1, and also demonstrates object serialization and data compression.
IntList.java: a simple datatype that defines custom serialziation and de-serialization behavior for itself.
MultiLineLabel.java: a custom AWT component and Java Bean that displays a specified string of text, using multiple lines, if the string contains newline characters.
YesNoDialog.java: a bean that displays a dialog box.
AnswerEvent.java: an event type used by the bean.
AnswerListener.java: the event listener interface used by the bean
YesNoDialogBeanInfo.java: a BeanInfo class for the bean.
YesNoDialogAlignmentEditor.java: a property editor class for one of the bean's properties.
YesNoDialogMessageEditor.java: a property editor class for another of the bean's properties.
YesNoDialogCustomizer.java: a customizer class for the bean.
ConvertEncoding.java: an application that converts a file from one character encoding to another.
Portfolio.java: a dummy stock portfolio program that demonstrates internationalization of dates, times and numbers.
SimpleMenu.java: a convenience class for simple creation of localized menus using ResourceBundles.
Menus.properties Menus_en_GB.properties Menus_fr.properties: property files that specify default, British, and French resource bundles for simple menu creation.
LocalizedError.java: a class that displays a localized error message fora given exception object, using the MessageFormat class.
Errors.properties: a sample property file used by the previous example
ShowClass.java: a program that uses the Reflection API to show the fields and methods of a class.
UniversalActionListener.java: an ActionListener implementation that uses reflection to invoke a named method of an object.