|
|
|
Copyright
|
|
|
|
Preface
|
|
|
|
|
New Developments
|
|
|
|
|
Using This Book
|
|
|
|
|
Online Resources
|
|
|
|
|
Conventions Used in This Book
|
|
|
|
|
Using Code Examples
|
|
|
|
|
Safari Enabled
|
|
|
|
|
How to Contact Us
|
|
|
|
|
Acknowledgments
|
|
|
|
Chapter 1. A Modern Language
|
|
|
|
|
Section 1.1. Enter Java
|
|
|
|
|
Section 1.2. A Virtual Machine
|
|
|
|
|
Section 1.3. Java Compared with Other Languages
|
|
|
|
|
Section 1.4. Safety of Design
|
|
|
|
|
Section 1.5. Safety of Implementation
|
|
|
|
|
Section 1.6. Application and User-Level Security
|
|
|
|
|
Section 1.7. Java and the Web
|
|
|
|
|
Section 1.8. Java as a General Application Language
|
|
|
|
|
Section 1.9. A Java Road Map
|
|
|
|
Chapter 2. A First Application
|
|
|
|
|
Section 2.1. Java Tools and Environment
|
|
|
|
|
Section 2.2. HelloJava
|
|
|
|
|
Section 2.3. HelloJava2: The Sequel
|
|
|
|
|
Section 2.4. HelloJava3: The Button Strikes!
|
|
|
|
|
Section 2.5. HelloJava4: Netscape's Revenge
|
|
|
|
|
Section 2.6. Troubleshooting
|
|
|
|
Chapter 3. Tools of the Trade
|
|
|
|
|
Section 3.1. The Java VM
|
|
|
|
|
Section 3.2. Running Java Applications
|
|
|
|
|
Section 3.3. The Classpath
|
|
|
|
|
Section 3.4. The Java Compiler
|
|
|
|
|
Section 3.5. JAR Files
|
|
|
|
|
Section 3.6. Policy Files
|
|
|
|
Chapter 4. The Java Language
|
|
|
|
|
Section 4.1. Text Encoding
|
|
|
|
|
Section 4.2. Comments
|
|
|
|
|
Section 4.3. Types
|
|
|
|
|
Section 4.4. Statements and Expressions
|
|
|
|
|
Section 4.5. Exceptions
|
|
|
|
|
Section 4.6. Assertions
|
|
|
|
|
Section 4.7. Arrays
|
|
|
|
Chapter 5. Objects in Java
|
|
|
|
|
Section 5.1. Classes
|
|
|
|
|
Section 5.2. Methods
|
|
|
|
|
Section 5.3. Object Creation
|
|
|
|
|
Section 5.4. Object Destruction
|
|
|
|
|
Section 5.5. Enumerations
|
|
|
|
Chapter 6. Relationships Among Classes
|
|
|
|
|
Section 6.1. Subclassing and Inheritance
|
|
|
|
|
Section 6.2. Interfaces
|
|
|
|
|
Section 6.3. Packages and Compilation Units
|
|
|
|
|
Section 6.4. Visibility of Variables and Methods
|
|
|
|
|
Section 6.5. Arrays and the Class Hierarchy
|
|
|
|
|
Section 6.6. Inner Classes
|
|
|
|
Chapter 7. Working with Objects and Classes
|
|
|
|
|
Section 7.1. The Object Class
|
|
|
|
|
Section 7.2. The Class Class
|
|
|
|
|
Section 7.3. Reflection
|
|
|
|
|
Section 7.4. Annotations
|
|
|
|
Chapter 8. Generics
|
|
|
|
|
Section 8.1. Containers: Building a Better Mousetrap
|
|
|
|
|
Section 8.2. Enter Generics
|
|
|
|
|
Section 8.3. "There Is No Spoon"
|
|
|
|
|
Section 8.4. Parameterized Type Relationships
|
|
|
|
|
Section 8.5. Casts
|
|
|
|
|
Section 8.6. Writing Generic Classes
|
|
|
|
|
Section 8.7. Bounds
|
|
|
|
|
Section 8.8. Wildcards
|
|
|
|
|
Section 8.9. Generic Methods
|
|
|
|
|
Section 8.10. Arrays of Parameterized Types
|
|
|
|
|
Section 8.11. Case Study: The Enum Class
|
|
|
|
|
Section 8.12. Case Study: The
sort
( ) Method
|
|
|
|
|
Section 8.13. Conclusion
|
|
|
|
Chapter 9. Threads
|
|
|
|
|
Section 9.1. Introducing Threads
|
|
|
|
|
Section 9.2. Threading an Applet
|
|
|
|
|
Section 9.3. Synchronization
|
|
|
|
|
Section 9.4. Scheduling and Priority
|
|
|
|
|
Section 9.5. Thread Groups
|
|
|
|
|
Section 9.6. Thread Performance
|
|
|
|
|
Section 9.7. Concurrency Utilities
|
|
|
|
|
Section 9.8. Conclusion
|
|
|
|
Chapter 10. Working with Text
|
|
|
|
|
Section 10.1. Text-Related APIs
|
|
|
|
|
Section 10.2. Strings
|
|
|
|
|
Section 10.3. Internationalization
|
|
|
|
|
Section 10.4. Parsing and Formatting Text
|
|
|
|
|
Section 10.5. Printf-Style Formatting
|
|
|
|
|
Section 10.6. Formatting with the java.text Package
|
|
|
|
|
Section 10.7. Regular Expressions
|
|
|
|
Chapter 11. Core Utilities
|
|
|
|
|
Section 11.1. Math Utilities
|
|
|
|
|
Section 11.2. Dates and Times
|
|
|
|
|
Section 11.3. Timers
|
|
|
|
|
Section 11.4. Collections
|
|
|
|
|
Section 11.5. Properties
|
|
|
|
|
Section 11.6. The Preferences API
|
|
|
|
|
Section 11.7. The Logging API
|
|
|
|
|
Section 11.8. Observers and Observables
|
|
|
|
Chapter 12. Input/Output Facilities
|
|
|
|
|
Section 12.1. Streams
|
|
|
|
|
Section 12.2. Files
|
|
|
|
|
Section 12.3. Serialization
|
|
|
|
|
Section 12.4. Data Compression
|
|
|
|
|
Section 12.5. The NIO Package
|
|
|
|
Chapter 13. Network Programming
|
|
|
|
|
Section 13.1. Sockets
|
|
|
|
|
Section 13.2. Datagram Sockets
|
|
|
|
|
Section 13.3. Simple Serialized Object Protocols
|
|
|
|
|
Section 13.4. Remote Method Invocation
|
|
|
|
|
Section 13.5. Scalable I/O with NIO
|
|
|
|
Chapter 14. Programming for the Web
|
|
|
|
|
Section 14.1. Uniform Resource Locators (URLs)
|
|
|
|
|
Section 14.2. The URL Class
|
|
|
|
|
Section 14.3. Talking to Web Applications
|
|
|
|
|
Section 14.4. Web Services
|
|
|
|
Chapter 15. Web Applications and Web Services
|
|
|
|
|
Section 15.1. Web Application Technologies
|
|
|
|
|
Section 15.2. Web Applications
|
|
|
|
|
Section 15.3. WAR Files and Deployment
|
|
|
|
|
Section 15.4. Servlet Filters
|
|
|
|
|
Section 15.5. Building WAR Files with Ant
|
|
|
|
|
Section 15.6. Implementing Web Services
|
|
|
|
Chapter 16. Swing
|
|
|
|
|
Section 16.1. Components
|
|
|
|
|
Section 16.2. Events
|
|
|
|
|
Section 16.3. Event Summary
|
|
|
|
|
Section 16.4. The AWT Robot!
|
|
|
|
|
Section 16.5. Multithreading in Swing
|
|
|
|
Chapter 17. Using Swing Components
|
|
|
|
|
Section 17.1. Buttons and Labels
|
|
|
|
|
Section 17.2. HTML Text in Buttons and Labels
|
|
|
|
|
Section 17.3. Checkboxes and Radio Buttons
|
|
|
|
|
Section 17.4. Lists and Combo Boxes
|
|
|
|
|
Section 17.5. The Spinner
|
|
|
|
|
Section 17.6. Borders
|
|
|
|
|
Section 17.7. Menus
|
|
|
|
|
Section 17.8. Pop-up Menus
|
|
|
|
|
Section 17.9. Component-Managed Pop-ups
|
|
|
|
|
Section 17.10. The JScrollPane Class
|
|
|
|
|
Section 17.11. The JSplitPane Class
|
|
|
|
|
Section 17.12. The JTabbedPane Class
|
|
|
|
|
Section 17.13. Scrollbars and Sliders
|
|
|
|
|
Section 17.14. Dialogs
|
|
|
|
|
Section 17.15. File Selection Dialog
|
|
|
|
|
Section 17.16. The Color Chooser
|
|
|
|
Chapter 18. More Swing Components
|
|
|
|
|
Section 18.1. Text Components
|
|
|
|
|
Section 18.2. Focus Navigation
|
|
|
|
|
Section 18.3. Tables
|
|
|
|
|
Section 18.4. Desktops
|
|
|
|
|
Section 18.5. Pluggable Look-and-Feel
|
|
|
|
|
Section 18.6. Creating Custom Components
|
|
|
|
Chapter 19. Layout Managers
|
|
|
|
|
Section 19.1. FlowLayout
|
|
|
|
|
Section 19.2. GridLayout
|
|
|
|
|
Section 19.3. BorderLayout
|
|
|
|
|
Section 19.4. BoxLayout
|
|
|
|
|
Section 19.5. CardLayout
|
|
|
|
|
Section 19.6. GridBagLayout
|
|
|
|
|
Section 19.7. Nonstandard Layout Managers
|
|
|
|
|
Section 19.8. Absolute Positioning
|
|
|
|
|
Section 19.9. SpringLayout
|
|
|
|
Chapter 20. Drawing with the 2D API
|
|
|
|
|
Section 20.1. The Big Picture
|
|
|
|
|
Section 20.2. The Rendering Pipeline
|
|
|
|
|
Section 20.3. A Quick Tour of Java 2D
|
|
|
|
|
Section 20.4. Filling Shapes
|
|
|
|
|
Section 20.5. Stroking Shape Outlines
|
|
|
|
|
Section 20.6. Using Fonts
|
|
|
|
|
Section 20.7. Displaying Images
|
|
|
|
|
Section 20.8. Drawing Techniques
|
|
|
|
|
Section 20.9. Printing
|
|
|
|
Chapter 21. Working with Images and Other Media
|
|
|
|
|
Section 21.1. Loading Images
|
|
|
|
|
Section 21.2. Producing Image Data
|
|
|
|
|
Section 21.3. Filtering Image Data
|
|
|
|
|
Section 21.4. Saving Image Data
|
|
|
|
|
Section 21.5. Simple Audio
|
|
|
|
|
Section 21.6. Java Media Framework
|
|
|
|
Chapter 22. JavaBeans
|
|
|
|
|
Section 22.1. What's a Bean?
|
|
|
|
|
Section 22.2. The NetBeans IDE
|
|
|
|
|
Section 22.3. Properties and Customizers
|
|
|
|
|
Section 22.4. Event Hookups and Adapters
|
|
|
|
|
Section 22.5. Binding Properties
|
|
|
|
|
Section 22.6. Building Beans
|
|
|
|
|
Section 22.7. Limitations of Visual Design
|
|
|
|
|
Section 22.8. Serialization Versus Code Generation
|
|
|
|
|
Section 22.9. Customizing with BeanInfo
|
|
|
|
|
Section 22.10. Hand-Coding with Beans
|
|
|
|
|
Section 22.11. BeanContext and BeanContextServices
|
|
|
|
|
Section 22.12. The Java Activation Framework
|
|
|
|
|
Section 22.13. Enterprise JavaBeans
|
|
|
|
Chapter 23. Applets
|
|
|
|
|
Section 23.1. The Politics of Applets
|
|
|
|
|
Section 23.2. The JApplet Class
|
|
|
|
|
Section 23.3. Using the Java Plug-in
|
|
|
|
|
Section 23.4. Java Web Start
|
|
|
|
|
Section 23.5. Using Digital Signatures
|
|
|
|
|
Section 23.6. Conclusion
|
|
|
|
Chapter 24. XML
|
|
|
|
|
Section 24.1. A Bit of Background
|
|
|
|
|
Section 24.2. XML Basics
|
|
|
|
|
Section 24.3. SAX
|
|
|
|
|
Section 24.4. DOM
|
|
|
|
|
Section 24.5. XPath
|
|
|
|
|
Section 24.6. XInclude
|
|
|
|
|
Section 24.7. Validating Documents
|
|
|
|
|
Section 24.8. JAXB and Code Generation
|
|
|
|
|
Section 24.9. Transforming Documents with XSL/XSLT
|
|
|
|
|
Section 24.10. Web Services
|
|
|
|
|
Section 24.11. The End of the Book
|
|
|
|
Appendix A. The Eclipse IDE
|
|
|
|
|
Section A.1. The IDE Wars
|
|
|
|
|
Section A.2. Getting Started with Eclipse
|
|
|
|
|
Section A.3. Using Eclipse
|
|
|
|
|
Section A.4. Eclipse Features
|
|
|
|
|
Section A.5. Conclusion
|
|
|
|
Appendix B. BeanShell: Simple Java Scripting
|
|
|
|
|
Section B.1. Running BeanShell
|
|
|
|
|
Section B.2. Java Statements and Expressions
|
|
|
|
|
Section B.3. BeanShell Commands
|
|
|
|
|
Section B.4. Scripted Methods and Objects
|
|
|
|
|
Section B.5. Changing the Classpath
|
|
|
|
|
Section B.6. Learning More . . .
|
|
|
|
Glossary
|
|
|
|
Colophon
|
|
|
|
|
About the Authors
|
|
|
|
|
Colophon
|
|
|
|
Index
|