David Gulbransen
Kenrick Rawlings
Sams.net Publishing
201 West 103rd Street, Indianapolis, Indiana 46290
FIRST EDITION
All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without written permission from the publisher. No patent liability
is assumed with respect to the use of the information contained herein. Although every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions. Neither is any liability assumed
for damages resulting from the use of the information contained herein. For information, address Sams.net Publishing, 201 W. 103rd St., Indianapolis, IN 46290.
International Standard Book Number: 1-57521-070-3
Library of Congress Catalog Card Number: 95-072940
99 98 97 96 4 3 2 1
Interpretation of the printing code: the rightmost double-digit number is the year of the book's printing; the rightmost single-digit, the number of the book's printing. For example, a printing code of 96-1 shows that the first printing of the book
occurred in 1996.
Printed in the United States of America
All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. Sams.net Publishing cannot attest to the accuracy of this information. Use of a term in this book should not be regarded as affecting
the validity of any trademark or service mark.
Java is a trademark of Sun Microsystems, Inc.
President, Sams Publishing:
Richard K. Swadley
Publishing Manager:
Mark Taber
Managing Editor:
Cindy Morrow
Marketing Manager:
John Pierce
Assistant Marketing Manager:
Kristina Perry
Acquisitions Editor
Beverly Eppink
Development Editor
Fran Hatton
Software Development Specialist
Merle Newlon
Production/Copy Editor
Heather Stith
Technical Reviewer
Sue Charlesworth
Editorial Coordinator
Bill Whitmer
Technical Edit Coordinator
Lynette Quinn
Resource Coordinator
Deborah Frisby
Formatter
Frank Sinclair
Editorial Assistants
Carol Ackerman
Andi Richter
Rhonda Tinch-Mize
Cover Designer
Jason Grisham
Book Designer
Gary Adair
Copy Writer
Peter Fuller
Production Team Supervisor
Brad Chinn
Introduction
I. Introduction to Java
1 What Is Java?
2 Uses and Restrictions of Java
II. Using Java
3 Java Browsers
4 Java's Capabilities
III. Adding Applets to Your Web Pages
5 Finding and Using Applets
6 Java-Enhanced Page Design
IV. Learning to Program Java
7 The Java Developer's Kit
8 Speaking Java: Java Syntax
9 Java Objects
V. Applet Programming
10 Applet Structure and Design
11 Building a User Interface
VI. Programming Complete Applets
12 The TickerTape Applet
13 The SlideShow Applet
Glossary of Terms
A Java Resources on the Net
B JavaScript and Java Language Reference
C 50 Useful Java Applets
D What's on the CD-ROM
Index
To Stephanie, for your love and support.
And to my father, for never losing faith in me.
David Gulbransen
To my father, for always being there.
Ken Rawlings
Thanks to Andy Granger, for putting up with us. Thanks to Jim Causey, for putting up with us. Thanks to the Dynamic Duo, for putting up with us. Paul, Clarence, and Alabama, thanks for the CDs! Thanks to our families: the Gulbransens, the
Berlins, the Rawlings, the Morefords, and the McKees (Whew!).
Fran Hatton: Thanks! Thanks! Thanks! Thanks to Beverly Eppink, for the opportunity. Thanks to Dan Friedman, for showing that programming is more than just coding. Thanks also to Mark Lynch, Mark Tabor, and John December.
Thanks also to the Java Development Team, Sun Microsystems/JavaSoft, the ACCESS MicroCenter at Indiana University, and the Henry Radford Hope School of Fine Arts.
David Gulbransen ([email protected]) is currently the Computing Specialist for the Indiana University school of Fine Arts. He is also a principal partner in Grey Associates, a Java software development
and consulting firm. Occasionally, Dave likes to put down the mouse for a movie camera to pursue his hobby of cinematography. He wants Kens cats.
Ken Rawlings ([email protected]) is currently employed at Indiana University as a software specialist at the ACCESS MicroCenter. He is also the Principal Software Architect for Grey Associates.
In his copious amounts of spare time, Ken enjoys coding Scheme, coding Delphi, and listening to the soulful sounds of James Brown. He has two very popular cats.
Billy Barron ([email protected]) is currently the Network Services Manager for the University of Texas at Dallas and has a M.S. in Computer Science from the University of North Texas. He has written and
technically reviewed such books as Tricks of the Internet Gurus, Education on the Internet, and Accessing Online Bibliographic Databases, as well as writing for periodicals.
Lay Wah Ooi ([email protected]) is a Computer Systems Engineer at Titan Spectrum Technologies. She graduated with a Computer Science degree from the University of North Texas. Lay Wah has contributed to Sams.net
Publishing's Internet Unleashed and was a technical editor for Java Unleashed.
The question, What is Java? often only leads to more questions. Some people see Java as yet another bit of Internet hype. Others see Java as the future of the Internet and Internet applications. In truth, Java probably lies somewhere in
between the extremes.
We hope that this book will begin to show you what Java is and what Java is not. Java is new, and Java is exciting. But Java is not the solution to every computing problem. Java is, quite simply, a new object-oriented programming language. With it comes
the advantages of object-oriented programming and several other advantages that have been created through Javas development process.
Java has been presented in many different ways by many different interests, but at the heart of all the Java hype is the language itself. Many people are confused or scared about what using Java means. What we hope to accomplish with this book is to
provide you with some answers.
Part I takes a first look at Java. Youll see where Java has been and where its headed. Youll also take a look at what Java is capable of and hopefully youll finish these chapters as excited about Java as we are.
Part II approaches Java from a users standpoint. How do you view Java applets and applications? What are the limits of what Java can do? What are the real-world uses for Java, and when is Java not enough?
Part III discusses how you can start using Java applets in your own Web development projects. You'll learn where to find Java applets, how to add those applets to your Web pages, and how to customize them.
Once youve seen what Java can do and have started adding Java to your pages, Parts 4 and 5 will teach you more about the language and take you through the basics of programming your own applets.
Finally, Chapters 12 and 13 provide you with some real-world applet examples. You can see the development of two working applets from beginning to end. Use this part as a starting point for developing your own applets and as a general guide for
programming.