| |
| |
Introduction | |
| |
| |
| |
Getting Started with Java Programming | |
| |
| |
| |
A Fistful of Java | |
| |
| |
What Java Is | |
| |
| |
Born to Run...on the Web | |
| |
| |
The Unauthorized Biography | |
| |
| |
Versions of the Language | |
| |
| |
Tell Me, Tell Me, Crystal Ball | |
| |
| |
Why Are You Here? | |
| |
| |
Java Is Platform Independent | |
| |
| |
Java Is Object-Oriented | |
| |
| |
Java Is Easy to Learn | |
| |
| |
Diving into Java Programming | |
| |
| |
Selecting a Java Development Tool | |
| |
| |
Installing the Java Development Kit | |
| |
| |
Your First Java Application | |
| |
| |
Summary | |
| |
| |
QandA | |
| |
| |
| |
A Taste of Object-Oriented Programming | |
| |
| |
Thinking in Terms of Objects | |
| |
| |
Objects and Classes | |
| |
| |
An Example of Class Design | |
| |
| |
Attributes and Behavior | |
| |
| |
Attributes of a Class of Objects | |
| |
| |
Behavior of a Class of Objects | |
| |
| |
Creating a Class | |
| |
| |
Running the Program | |
| |
| |
Organizing Classes and Class Behavior | |
| |
| |
Inheritance | |
| |
| |
Creating a Class Hierarchy | |
| |
| |
Inheritance in Action | |
| |
| |
Single and Multiple Inheritance | |
| |
| |
Interfaces | |
| |
| |
Packages | |
| |
| |
Creating a Subclass | |
| |
| |
Summary | |
| |
| |
QandA | |
| |
| |
| |
The ABCs of Java | |
| |
| |
Statements and Expressions | |
| |
| |
Variables and Data Types | |
| |
| |
Creating Variables | |
| |
| |
Naming Variables | |
| |
| |
Variable Types | |
| |
| |
Assigning Values to Variables | |
| |
| |
Comments | |
| |
| |
Literals | |
| |
| |
Number Literals | |
| |
| |
Boolean Literals | |
| |
| |
Character Literals | |
| |
| |
String Literals | |
| |
| |
Expressions and Operators | |
| |
| |
Arithmetic | |
| |
| |
More About Assignment | |
| |
| |
Incrementing and Decrementing | |
| |
| |
Comparisons | |
| |
| |
Logical Operators | |
| |
| |
Operator Precedence | |
| |
| |
String Arithmetic | |
| |
| |
Summary | |
| |
| |
QandA | |
| |
| |
| |
Object Lessons | |
| |
| |
Creating New Objects | |
| |
| |
Using new | |
| |
| |
What new Does | |
| |
| |
A Note on Memory Management | |
| |
| |
Accessing and Setting Class and Instance Variables | |
| |
| |
Getting Values | |
| |
| |
Changing Values | |
| |
| |
Class Variables | |
| |
| |
Calling Methods | |
| |
| |
Class Methods | |
| |
| |
References to Objects | |
| |
| |
Casting and Converting Objects and Primitive Types | |
| |
| |
Casting Primitive Types | |
| |
| |
Casting Objects | |
| |
| |
Converting Primitive Types to Objects and Vice Versa | |
| |
| |
Comparing Object Values and Classes | |
| |
| |
Comparing Objects | |
| |
| |
Determining the Class of an Object | |
| |
| |
Inspecting Classes and Methods with Reflection | |
| |
| |
Summary | |
| |
| |
QandA | |
| |
| |
| |
Lists, Logic, and Loops | |
| |
| |
Arrays | |
| |
| |
Declaring Array Variables | |
| |
| |
Creating Array Objects | |
| |
| |
Accessing Array Elements | |
| |
| |
Changing Array Elements | |
| |
| |
Multidimensional Arrays | |
| |
| |
Block Statements | |
| |
| |
if Conditionals | |
| |
| |
The Conditional Operator | |
| |
| |
switch Conditionals | |
| |
| |
for Loops | |
| |
| |
while and do Loops | |
| |
| |
while Loops | |
| |
| |
do...while Loops | |
| |
| |
Breaking Out of Loops | |
| |
| |
Labeled Loops | |
| |
| |
Summary | |
| |
| |
QandA | |
| |
| |
| |
Creating Classes | |
| |
| |
Defining Classes | |
| |
| |
Creating Instance and Class Variables | |
| |
| |
Defining Instance Variables | |
| |
| |
Constants | |
| |
| |
Class Variables | |
| |
| |
Creating Methods | |
| |
| |
Defining Methods | |
| |
| |
The this Keyword | |
| |
| |
Variable Scope and Method Definitions | |
| |
| |
Passing Arguments to Methods | |
| |
| |
Class Methods | |
| |
| |
Creating Java Applications | |
| |
| |
Helper Classes | |
| |
| |
Java Applications and Command-Line Arguments | |
| |
| |
Passing Arguments to Java Applications | |
| |
| |
Handling Arguments in Your Java Application | |
| |
| |
Summary | |
| |
| |
QandA | |
| |
| |
| |
Using Methods to Accomplish Tasks | |
| |
| |
Creating Methods with the Same Name, Different Arguments | |
| |
| |
Constructor Methods | |
| |
| |
Basic Constructors Methods | |
| |
| |
Calling Another Constructor Method | |
| |
| |
Overloading Constructor Methods | |
| |
| |
Overriding Methods | |
| |
| |
Creating Methods That Override Existing Methods | |
| |
| |
Calling the Original Method | |
| |
| |
Overriding Constructors | |
| |
| |
Finalizer Methods | |
| |
| |
Summary | |
| |
| |
QandA | |
| |
| |
| |
Moving into Advanced Java | |
| |
| |
| |
Putting Interactive Programs on the Web | |
| |
| |
How Applets and Applications Are Different | |
| |
| |
Applet Security Restrictions | |
| |
| |
Choosing a Java Version | |
| |
| |
Enhanced Control of Security | |
| |
| |
Creating Applets | |
| |
| |
Major Applet Activities | |
| |
| |
A Simple Applet | |
| |
| |
Including an Applet on a Web Page | |
| |
| |
The [APPLET] Tag | |
| |
| |
Testing the Result | |
| |
| |
Putting Applets on the Web | |
| |
| |
More About the [APPLET] Tag | |
| |
| |
ALIGN | |
| |
| |
HSPACE and VSPACE | |
| |
| |
CODE and CODEBASE | |
| |
| |
The [OBJECT] Tag | |
| |
| |
Java Archives | |
| |
| |
Other Archival Formats | |
| |
| |
Passing Parameters to Applets | |
| |
| |
Summary | |
| |
| |
QandA | |
| |
| |
| |
Making Programs Look Good with Graphics, Fonts, and Color | |
| |
| |
The Graphics Class | |
| |
| |
The Graphics Coordinate System | |
| |
| |
Drawing and Filling | |
| |
| |
Lines | |
| |
| |
Rectangles | |
| |
| |
Ovals | |
| |
| |
Arcs | |
| |
| |
Copying and Clearing | |
| |
| |
Text and Fonts | |
| |
| |
Creating Font Objects | |
| |
| |
Drawing Characters and Strings | |
| |
| |
Finding Information About a Font | |
| |
| |
Color | |
| |
| |
Using Color Objects | |
| |
| |
Testing and Setting the Current Colors | |
| |
| |
Advanced Graphics Operations Using Java2D | |
| |
| |
User and Device Coordinate Spaces | |
| |
| |
Casting a Graphics2D Object | |
| |
| |
Specifying the Rendering Attributes | |
| |
| |
Creating Objects to Draw | |
| |
| |
Drawing Objects | |
| |
| |
Summary | |
| |
| |
QandA | |
| |
| |
| |
Adding Images, Animation, and Sound | |
| |
| |
Creating Animation in Java | |
| |
| |
Painting and Repainting | |
| |
| |
Starting and Stopping an Applet's Execution | |
| |
| |
Controlling Animation Through Threads | |
| |
| |
Writing Applets with Threads | |
| |
| |
Putting It Together | |
| |
| |
Reducing Animation Flickering | |
| |
| |
Flickering and How to Avoid It | |
| |
| |
How to Override update () | |
| |
| |
One Solution: Don't Clear the Screen | |
| |
| |
Retrieving and Using Images | |
| |
| |
Getting Images | |
| |
| |
Relative File Paths | |
| |
| |
Drawing Images | |
| |
| |
A Note About Image Observers | |
| |
| |
Putting Images to Work | |
| |
| |
Creating Animation Using Images | |
| |
| |
An Example: Neko | |
| |
| |
A Note on Disposing of Graphics Contexts | |
| |
| |
Double-Buffering | |
| |
| |
The Checkers Applet | |
| |
| |
Retrieving and Using Sounds | |
| |
| |
Summary | |
| |
| |
QandA | |
| |
| |
| |
Building Simple User Interfaces for Applets | |
| |
| |
The Abstract Windowing Toolkit | |
| |
| |
User-Interface Components | |
| |
| |
Adding Components to a Container | |
| |
| |
Labels | |
| |
| |
Buttons | |
| |
| |
Check Boxes | |
| |
| |
Choice Lists | |
| |
| |
Text Fields | |
| |
| |
Text Areas | |
| |
| |
Scrolling Lists | |
| |
| |
Scrollbars and Sliders | |
| |
| |
Canvases | |
| |
| |
Summary | |
| |
| |
QandA | |
| |
| |
| |
Arranging Components on a User Interface | |
| |
| |
Basic Interface Layout | |
| |
| |
Laying Out an Interface | |
| |
| |
Flow Layout | |
| |
| |
Grid Layout | |
| |
| |
Border Layout | |
| |
| |
Mixing Layout Managers | |
| |
| |
Advanced Interface Layout | |
| |
| |
Card Layout | |
| |
| |
Grid Bag Layout | |
| |
| |
Insets | |
| |
| |
Summary | |
| |
| |
QandA | |
| |
| |
| |
Responding to User Input in an Applet | |
| |
| |
Event Handling | |
| |
| |
Types of Events | |
| |
| |
The handleEvent () Method | |
| |
| |
Handling Mouse Clicks | |
| |
| |
Mouse Down and Mouse Up Events | |
| |
| |
An Example: Spots | |
| |
| |
Double-Clicks | |
| |
| |
Handling Mouse Movements | |
| |
| |
Mouse Drag and Mouse Move Events | |
| |
| |
Mouse Enter and Mouse Exit Events | |
| |
| |
An Example: Drawing Lines | |
| |
| |
Handling Keyboard Events | |
| |
| |
Key Down and Key Up Events | |
| |
| |
Default Keys | |
| |
| |
An Example: Entering, Displaying, and Moving Characters | |
| |
| |
Testing for Modifier Keys and Multiple Mouse Buttons | |
| |
| |
The Generic Event Handler | |
| |
| |
Handling Component Events | |
| |
| |
Handling Action Events | |
| |
| |
Handling Focus Events | |
| |
| |
Text Area Events | |
| |
| |
Scrolling List Events | |
| |
| |
An Example: Background Color Switcher | |
| |
| |
Adding the Event Code | |
| |
| |
Summary | |
| |
| |
QandA | |
| |
| |
| |
Developing Advanced User Interfaces with the AWT | |
| |
| |
Windows, Frames, and Dialog Boxes | |
| |
| |
The Window Classes | |
| |
| |
Frames | |
| |
| |
Dialog Boxes | |
| |
| |
Window Events | |
| |
| |
Menus | |
| |
| |
Menus and Menu Bars | |
| |
| |
Menu Items | |
| |
| |
Menu Event | |
| |
| |
Creating Standalone AWT Applications | |
| |
| |
A Complete Example: RGB-to-HSB Converter | |
| |
| |
Designing and Creating the Applet Layout | |
| |
| |
Defining the Subpanels | |
| |
| |
Handling the Events | |
| |
| |
Updating the Result | |
| |
| |
The Complete Source Code | |
| |
| |
Summary | |
| |
| |
QandA | |
| |
| |
| |
Rounding Out Your Knowledge of Java | |
| |
| |
| |
Class Roles: Packages, Interfaces, and Other Features | |
| |
| |
Modifiers | |
| |
| |
Access Control for Methods and Variables | |
| |
| |
Static Variables and Methods | |
| |
| |
Final Classes, Methods, and Variables | |
| |
| |
Variables | |
| |
| |
Methods | |
| |
| |
Classes | |
| |
| |
Abstract Classes and Methods | |
| |
| |
Packages | |
| |
| |
Using Packages | |
| |
| |
Full Package and Class Names | |
| |
| |
The import Command | |
| |
| |
Name Conflicts | |
| |
| |
A Note About CLASSPATH and Where Classes Are Located | |
| |
| |
Creating Your Own Packages | |
| |
| |
Picking a Package Name | |
| |
| |
Creating the Folder Structure | |
| |
| |
Adding a Class to a Package | |
| |
| |
Packages and Class Access Control | |
| |
| |
Interfaces | |
| |
| |
The Problem of Single Inheritance | |
| |
| |
Interfaces and Classes | |
| |
| |
Implementing and Using Interfaces | |
| |
| |
Implementing Multiple Interfaces | |
| |
| |
Other Uses of Interfaces | |
| |
| |
Creating and Extending Interfaces | |
| |
| |
New Interfaces | |
| |
| |
Methods Inside Interfaces | |
| |
| |
Extending Interfaces | |
| |
| |
An Example: Enumerating Linked Lists | |
| |
| |
Inner Classes | |
| |
| |
Summary | |
| |
| |
QandA | |
| |
| |
| |
Exceptional Circumstances: Error Handling and Security | |
| |
| |
Exceptions, the Old and Confusing Way | |
| |
| |
Java Exceptions | |
| |
| |
Managing Exceptions | |
| |
| |
Exception Consistency Checking | |
| |
| |
Protecting Code and Catching Exceptions | |
| |
| |
The finally Clause | |
| |
| |
Declaring Methods That Might Throw Exceptions | |
| |
| |
The throws Clause | |
| |
| |
Which Exceptions Should You Throw? | |
| |
| |
Passing On Exceptions | |
| |
| |
throws and Inheritance | |
| |
| |
Creating and Throwing Your Own Exceptions | |
| |
| |
Throwing Exceptions | |
| |
| |
Creating Your Own Exceptions | |
| |
| |
Combining throws, try, and throw | |
| |
| |
When and When Not to Use Exceptions | |
| |
| |
When to Use Exceptions | |
| |
| |
When Not to Use Exceptions | |
| |
| |
Bad Style Using Exceptions | |
| |
| |
Using Digital Signatures to Identify Applets | |
| |
| |
A Digital Signature Example | |
| |
| |
Browser-Specific Signatures | |
| |
| |
Security Policies | |
| |
| |
Summary | |
| |
| |
QandA | |
| |
| |
| |
Handling Data Through Java Streams | |
| |
| |
Introduction to Streams | |
| |
| |
Using a Stream | |
| |
| |
Filtering a Stream | |
| |
| |
Byte Streams | |
| |
| |
File Streams | |
| |
| |
Filtering a Stream | |
| |
| |
Byte Filters | |
| |
| |
Character Streams | |
| |
| |
Reading Text Files | |
| |
| |
Writing Text Files | |
| |
| |
Files and Filename Filters | |
| |
| |
Summary | |
| |
| |
QandA | |
| |
| |
| |
Communicating Across the Internet | |
| |
| |
Networking in Java | |
| |
| |
Opening Web Connections | |
| |
| |
Opening a Stream Over the Net | |
| |
| |
Sockets | |
| |
| |
Trivia: A Simple Socket Client and Server | |
| |
| |
Designing Trivia | |
| |
| |
Implementing the Trivia Server | |
| |
| |
Implementing the Trivia Client | |
| |
| |
Running Trivia | |
| |
| |
Summary | |
| |
| |
QandA | |
| |
| |
| |
JavaBeans and Other Advanced Features | |
| |
| |
JavaBeans | |
| |
| |
The Goal of JavaBeans | |
| |
| |
How JavaBeans Relates to Java | |
| |
| |
The JavaBeans API | |
| |
| |
Applet Tricks | |
| |
| |
The showStatus () Method | |
| |
| |
Applet Information | |
| |
| |
Creating Links Inside Applets | |
| |
| |
Communicating Between Applets | |
| |
| |
Cut, Copy, and Paste | |
| |
| |
Creating Transferable Objects | |
| |
| |
Using the Clipboard | |
| |
| |
Remote Method Invocation | |
| |
| |
The RMI Architecture | |
| |
| |
Creating RMI Applications | |
| |
| |
Java Database Connectivity | |
| |
| |
Summary | |
| |
| |
QandA | |
| |
| |
| |
Designing a User Interface with Swing | |
| |
| |
The Benefits of Swing | |
| |
| |
An Application Framework | |
| |
| |
Adding Components to a Swing Frame | |
| |
| |
Working with Swing | |
| |
| |
Labels | |
| |
| |
Buttons | |
| |
| |
Text Fields | |
| |
| |
Text Areas | |
| |
| |
Check Boxes and Radio Buttons | |
| |
| |
Choice Lists | |
| |
| |
Scrollbars | |
| |
| |
An Example: The SwingColorTest Application | |
| |
| |
New Features of Swing | |
| |
| |
Setting the Look and Feel | |
| |
| |
Keyboard Mnemonics | |
| |
| |
ToolTips | |
| |
| |
Component Descriptions and Names | |
| |
| |
Standard Dialog Boxes | |
| |
| |
An Example: The Info Application | |
| |
| |
Summary | |
| |
| |
QandA | |
| |
| |
| |
Handling User Events with Swing | |
| |
| |
The Main Event | |
| |
| |
Event Listeners | |
| |
| |
Setting Up Components | |
| |
| |
Event-Handling Methods | |
| |
| |
Working with Methods | |
| |
| |
Action Events | |
| |
| |
Adjustment Events | |
| |
| |
Focus Events | |
| |
| |
Item Events | |
| |
| |
Key Events | |
| |
| |
Mouse Events | |
| |
| |
Mouse-Movement Events | |
| |
| |
Window Events | |
| |
| |
An Example: The SwingColorTest Application | |
| |
| |
Summary | |
| |
| |
QandA | |
| |
| |
Appendixes | |
| |
| |
| |
Java Language Summary | |
| |
| |
Reserved Words | |
| |
| |
Comments | |
| |
| |
Literals | |
| |
| |
Variable Declaration | |
| |
| |
Variable Assignment | |
| |
| |
Operators | |
| |
| |
Objects | |
| |
| |
Arrays | |
| |
| |
Loops and Conditionals | |
| |
| |
Class Definitions | |
| |
| |
Method and Constructor Definitions | |
| |
| |
Importing | |
| |
| |
Guarding | |
| |
| |
| |
The Java Class Library | |
| |
| |
java.applet | |
| |
| |
java.awt | |
| |
| |
java.awt.accessibility | |
| |
| |
java.awt.color | |
| |
| |
java.awt.datatransfer | |
| |
| |
java.awt.dnd | |
| |
| |
java.awt.event | |
| |
| |
java.awt.font | |
| |
| |
java.awt.geom | |
| |
| |
java.awt.im | |
| |
| |
java.awt.image | |
| |
| |
java.awt.peer | |
| |
| |
java.awt.print | |
| |
| |
java.awt.swing | |
| |
| |
java.awt.swing.event | |
| |
| |
java.awt.swing.undo | |
| |
| |
java.beans | |
| |
| |
java.bean.beancontext | |
| |
| |
java.io | |
| |
| |
java.lang | |
| |
| |
java.lang.ref | |
| |
| |
java.lang.reflect | |
| |
| |
java.math | |
| |
| |
java.net | |
| |
| |
java.rmi | |
| |
| |
java.rmi.activation | |
| |
| |
java.rmi.dgc | |
| |
| |
java.rmi.registry | |
| |
| |
java.rmi.server | |
| |
| |
java.security | |
| |
| |
java.security.acl | |
| |
| |
java.security.cert | |
| |
| |
java.security.interfaces | |
| |
| |
java.security.spec | |
| |
| |
java.sql | |
| |
| |
java.text | |
| |
| |
java.util | |
| |
| |
java.util.jar | |
| |
| |
java.util.mime | |
| |
| |
java.util.zip | |
| |
| |
| |
Java Resources on the Internet | |
| |
| |
This Book's Web Site | |
| |
| |
Other Books to Consider | |
| |
| |
The Sun Microsystems Site | |
| |
| |
Other Java Web Sites | |
| |
| |
The Java Books Page | |
| |
| |
Gamelan's Java Directory | |
| |
| |
Java Applet Rating Service | |
| |
| |
JavaWorld Magazine | |
| |
| |
Java Frequently Asked Questions | |
| |
| |
Java Newsgroups | |
| |
| |
Job Opportunities | |
| |
| |
| |
Configuring the Java Development Kit | |
| |
| |
Windows 95 and Windows NT Configuration | |
| |
| |
Checking the PATH Statement | |
| |
| |
Changing Your PATH Setting | |
| |
| |
Fixing Class not found Errors | |
| |
| |
UNIX Configuration | |
| |
| |
Fixing Class not found Errors on Other Platforms | |
| |
| |
| |
Using a Text Editor with the JDK | |
| |
| |
Choosing a Text Editor | |
| |
| |
Creating a File Association in Windows 95 | |
| |
| |
Delete an Existing File Association | |
| |
| |
Creating a New Association | |
| |
| |
Associating an Icon with a File Type | |
| |
| |
Index | |