Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Learning Java
A Note Regarding Supplemental Files
Preface
New Developments
New in This Edition
Using This Book
Online Examples
Online Resources
Conventions Used in This Book
Using Code Examples
Safari Enabled
How to Contact Us
Acknowledgments
1. A Modern Language
1.1. Enter Java
1.1.1. Java’s Origins
1.1.2. Growing Up
1.2. A Virtual Machine
1.3. Java Compared with Other Languages
1.4. Safety of Design
1.4.1. Simplify, Simplify, Simplify...
1.4.2. Type Safety and Method Binding
1.4.3. Incremental Development
1.4.4. Dynamic Memory Management
1.4.5. Error Handling
1.4.6. Threads
1.4.7. Scalability
1.5. Safety of Implementation
1.5.1. The Verifier
1.5.2. Class Loaders
1.5.3. Security Managers
1.6. Application and User-Level Security
1.6.1. Signing Classes
1.7. Java and the Web
1.7.1. Applets
1.7.2. New Kinds of Media
1.7.3. New Software Development Models
1.8. Java as a General Application Language
1.9. A Java Road Map
1.9.1. The Past: Java 1.0-Java 1.4
1.9.2. The Present: Java 5.0
1.9.3. The Future
1.9.4. Availability
2. A First Application
2.1. Java Tools and Environment
2.2. HelloJava
2.2.1. Classes
2.2.2. The main() Method
2.2.3. Classes and Objects
2.2.4. Variables and Class Types
2.2.5. HelloComponent
2.2.6. Inheritance
2.2.7. The JComponent Class
2.2.8. Relationships and Finger Pointing
2.2.9. Package and Imports
2.2.10. The paintComponent() Method
2.3. HelloJava2: The Sequel
2.3.1. Instance Variables
2.3.2. Constructors
2.3.3. Events
2.3.4. The repaint() Method
2.3.5. Interfaces
2.4. HelloJava3: The Button Strikes!
2.4.1. Method Overloading
2.4.2. Components
2.4.3. Containers
2.4.4. Layout
2.4.5. Subclassing and Subtypes
2.4.6. More Events and Interfaces
2.4.7. Color Commentary
2.4.8. Static Members
2.4.9. Arrays
2.4.10. Our Color Methods
2.5. HelloJava4: Netscape’s Revenge
2.5.1. Threads
2.5.2. The Thread Class
2.5.3. The Runnable Interface
2.5.4. Starting the Thread
2.5.5. Running Code in the Thread
2.5.6. Exceptions
2.5.7. Synchronization
2.6. Troubleshooting
2.6.1. Compilation (javac) Errors
2.6.2. Runtime (java) Errors
2.6.3. Java Version Problems
2.6.4. The getContentPane() Error
3. Tools of the Trade
3.1. The Java VM
3.2. Running Java Applications
3.2.1. System Properties
3.3. The Classpath
3.3.1. javap
3.4. The Java Compiler
3.5. JAR Files
3.5.1. File Compression
3.5.2. The jar Utility
3.5.2.1. JAR manifests
3.5.2.2. Making a JAR file runnable
3.5.3. The pack200 Utility
3.6. Policy Files
3.6.1. The Default Security Manager
3.6.2. The policytool Utility
3.6.3. Using a Policy File with the Default Security Manager
4. The Java Language
4.1. Text Encoding
4.2. Comments
4.2.1. Javadoc Comments
4.2.1.1. Javadoc as metadata
4.3. Types
4.3.1. Primitive Types
4.3.1.1. Floating-point precision
4.3.1.2. Variable declaration and initialization
4.3.1.3. Integer literals
4.3.1.4. Floating-point literals
4.3.1.5. Character literals
4.3.2. Reference Types
4.3.3. A Word About Strings
4.4. Statements and Expressions
4.4.1. Statements
4.4.1.1. if/else conditionals
4.4.1.2. do/while loops
4.4.1.3. The for loop
4.4.1.4. The enhanced for loop
4.4.1.5. switch statements
4.4.1.6. break/continue
4.4.1.7. Unreachable statements
4.4.2. Expressions
4.4.2.1. Operators
4.4.2.2. Assignment
4.4.2.3. The null value
4.4.2.4. Variable access
4.4.2.5. Method invocation
4.4.2.6. Object creation
4.4.2.7. The instanceof operator
4.5. Exceptions
4.5.1. Exceptions and Error Classes
4.5.2. Exception Handling
4.5.3. Bubbling Up
4.5.4. Stack Traces
4.5.5. Checked and Unchecked Exceptions
4.5.6. Throwing Exceptions
4.5.6.1. Chaining exceptions
4.5.7. try Creep
4.5.8. The finally Clause
4.5.9. Performance Issues
4.6. Assertions
4.6.1. Enabling and Disabling Assertions
4.6.2. Using Assertions
4.7. Arrays
4.7.1. Array Types
4.7.2. Array Creation and Initialization
4.7.3. Using Arrays
4.7.4. Anonymous Arrays
4.7.5. Multidimensional Arrays
4.7.6. Inside Arrays
5. Objects in Java
5.1. Classes
5.1.1. Accessing Fields and Methods
5.1.2. Static Members
5.1.2.1. Constants versus enumerations
5.2. Methods
5.2.1. Local Variables
5.2.2. Shadowing
5.2.2.1. The “this” reference
5.2.3. Static Methods
5.2.4. Initializing Local Variables
5.2.5. Argument Passing and References
5.2.6. Wrappers for Primitive Types
5.2.7. Autoboxing and Unboxing of Primitives
5.2.7.1. Performance implications of boxing
5.2.8. Variable-Length Argument Lists
5.2.9. Method Overloading
5.3. Object Creation
5.3.1. Constructors
5.3.2. Working with Overloaded Constructors
5.3.3. Static and Nonstatic Initializer Blocks
5.4. Object Destruction
5.4.1. Garbage Collection
5.4.2. Finalization
5.4.3. Weak and Soft References
5.5. Enumerations
5.5.1. Enum Values
5.5.2. Customizing Enumerations
6. Relationships Among Classes
6.1. Subclassing and Inheritance
6.1.1. Shadowed Variables
6.1.2. Overriding Methods
6.1.2.1. @Override
6.1.2.2. Overridden methods and dynamic binding
6.1.2.3. Static method binding
6.1.2.4. final methods and performance
6.1.2.5. Compiler optimizations
6.1.2.6. Method selection revisited
6.1.2.7. Exceptions and overridden methods
6.1.2.8. Return types and overridden methods
6.1.3. Special References: this and super
6.1.4. Casting
6.1.4.1. Casting aspersions
6.1.5. Using Superclass Constructors
6.1.6. Full Disclosure: Constructors and Initialization
6.1.7. Abstract Methods and Classes
6.2. Interfaces
6.2.1. Interfaces as Callbacks
6.2.2. Interface Variables
6.2.2.1. Flag interfaces
6.2.3. Subinterfaces
6.2.3.1. Overlapping and conflicting methods
6.3. Packages and Compilation Units
6.3.1. Compilation Units
6.3.2. Package Names
6.3.3. Class Visibility
6.3.4. Importing Classes
6.3.4.1. The unnamed package
6.3.4.2. Static imports
6.4. Visibility of Variables and Methods
6.4.1. Basic Access Modifiers
6.4.2. Subclasses and Visibility
6.4.3. Interfaces and Visibility
6.5. Arrays and the Class Hierarchy
6.5.1.
6.5.1.1. ArrayStoreException
6.6. Inner Classes
6.6.1. Inner Classes as Adapters
6.6.2. Inner Classes Within Methods
6.6.2.1. Limitations on inner classes in methods
6.6.2.2. Static inner classes
6.6.2.3. Anonymous inner classes
6.6.2.4. Scoping of the “this” reference
6.6.2.5. How do inner classes really work?
6.6.2.6. Security implications
7. Working with Objects and Classes
7.1. The Object Class
7.1.1. Equality and Equivalence
7.1.2. Hashcodes
7.1.3. Cloning Objects
7.2. The Class Class
7.3. Reflection
7.3.1. Modifiers and Security
7.3.2. Accessing Fields
7.3.3. Accessing Methods
7.3.4. Accessing Constructors
7.3.5. What About Arrays?
7.3.6. Accessing Generic Type Information
7.3.7. Accessing Annotation Data
7.3.8. Dynamic Interface Adapters
7.3.9. What Is Reflection Good For?
7.3.9.1. The BeanShell Java scripting language
7.4. Annotations
7.4.1. Using Annotations
7.4.2. Standard Annotations
7.4.3. The apt Tool
8. Generics
8.1. Containers: Building a Better Mousetrap
8.1.1. Can Containers Be Fixed?
8.2. Enter Generics
8.2.1. Talking About Types
8.3. “There Is No Spoon”
8.3.1. Erasure
8.3.2. Raw Types
8.4. Parameterized Type Relationships
8.4.1. Why Isn’t a List<Date> a List<Object>?
8.5. Casts
8.6. Writing Generic Classes
8.6.1. The Type Variable
8.6.2. Subclassing Generics
8.6.3. Exceptions and Generics
8.6.3.1. No generic Throwables
8.6.4. Parameter Type Limitations
8.6.4.1. Using Class<T>
8.7. Bounds
8.7.1. Erasure and Bounds (Working with Legacy Code)
8.8. Wildcards
8.8.1. A Supertype of All Instantiations
8.8.2. Bounded Wildcards
8.8.3. Thinking Outside the Container
8.8.4. Lower Bounds
8.8.5. Reading, Writing, and Arithmetic
8.8.6. <?>, <Object>, and the Raw Type
8.8.7. Wildcard Type Relationships
8.9. Generic Methods
8.9.1. Generic Methods Introduced
8.9.2. Type Inference from Arguments
8.9.3. Type Inference from Assignment Context
8.9.4. Explicit Type Invocation
8.9.5. Wildcard Capture
8.9.6. Wildcard Types Versus Generic Methods
8.10. Arrays of Parameterized Types
8.10.1. Using Array Types
8.10.2. What Good Are Arrays of Generic Types?
8.10.3. Wildcards in Array Types
8.11. Case Study: The Enum Class
8.12. Case Study: The sort() Method
8.13. Conclusion
9. Threads
9.1. Introducing Threads
9.1.1. The Thread Class and the Runnable Interface
9.1.1.1. Creating and starting threads
9.1.1.2. A natural-born thread
9.1.1.3. Using an adapter
9.1.2. Controlling Threads
9.1.2.1. Deprecated methods
9.1.2.2. The sleep() method
9.1.2.3. The join() method
9.1.2.4. The interrupt() method
9.1.3. Death of a Thread
9.2. Threading an Applet
9.2.1.
9.2.1.1. Issues lurking
9.3. Synchronization
9.3.1. Serializing Access to Methods
9.3.2.
9.3.2.1. Accessing variables
9.3.2.2. Reentrant locking
9.3.3. The wait() and notify() Methods
9.3.3.1. Wait conditions
9.3.4. Passing Messages
9.3.4.1. Food for thought
9.3.5. ThreadLocal Objects
9.4. Scheduling and Priority
9.4.1. Thread State
9.4.2. Time-Slicing
9.4.3. Priorities
9.4.4. Native Threads
9.4.5. Yielding
9.5. Thread Groups
9.5.1. Working with ThreadGroups
9.5.2. Uncaught Exceptions
9.6. Thread Performance
9.6.1. The Cost of Synchronization
9.6.2. Thread Resource Consumption
9.7. Concurrency Utilities
9.7.1. Executors
9.7.1.1. Tasks with results: Callable and Future
9.7.1.2. ExecutorService
9.7.1.3. Collective tasks
9.7.1.4. Scheduled tasks
9.7.1.5. CompletionService
9.7.1.6. The ThreadPoolExecutor implementation
9.7.1.7. Thread production
9.7.2. Locks
9.7.2.1. Read and write locks
9.7.2.2. Conditions
9.7.3. Synchronization Constructs
9.7.3.1. CountDownLatch
9.7.3.2. Semaphore
9.7.3.3. CyclicBarrier
9.7.3.4. Exchanger
9.7.4. Atomic Operations
9.7.4.1. Weak implementations
9.7.4.2. Field updaters
9.8. Conclusion
10. Working with Text
10.1. Text-Related APIs
10.2. Strings
10.2.1. Constructing Strings
10.2.2. Strings from Things
10.2.3. Comparing Strings
10.2.3.1. The Collator class
10.2.4. Searching
10.2.5. Editing
10.2.6. String Method Summary
10.2.7. StringBuilder and StringBuffer
10.3. Internationalization
10.3.1. The java.util.Locale Class
10.3.2. Resource Bundles
10.4. Parsing and Formatting Text
10.4.1. Parsing Primitive Numbers
10.4.1.1. Working with alternate bases
10.4.1.2. Number formats
10.4.2. Tokenizing Text
10.4.2.1. StringTokenizer
10.5. Printf-Style Formatting
10.5.1. Formatter
10.5.2. The Format String
10.5.3. String Conversions
10.5.3.1. Width, precision, and justification
10.5.3.2. Uppercase
10.5.3.3. Numbered arguments
10.5.4. Primitive and Numeric Conversions
10.5.5. Flags
10.5.6. Miscellaneous
10.6. Formatting with the java.text Package
10.6.1. MessageFormat
10.7. Regular Expressions
10.7.1. Regex Notation
10.7.1.1. Write once, run away
10.7.1.2. Escaped characters
10.7.1.3. Characters and character classes
10.7.1.4. Custom character classes
10.7.1.5. Position markers
10.7.1.6. Iteration (multiplicity)
10.7.1.7. Grouping
10.7.1.8. Capture groups
10.7.1.9. Numbering
10.7.1.10. Alternation
10.7.1.11. Special options
10.7.1.12. Greediness
10.7.1.13. Lookaheads and lookbehinds
10.7.2. The java.util.regex API
10.7.2.1. Pattern
10.7.2.2. The Matcher
10.7.2.3. Splitting and tokenizing strings
10.7.2.4. Another look at Scanner
10.7.2.5. Replacing text
10.7.2.6. The simple template engine
11. Core Utilities
11.1. Math Utilities
11.1.1. The java.lang.Math Class
11.1.2. The java.math Package
11.1.3. Random Numbers
11.2. Dates and Times
11.2.1. Working with Calendars
11.2.2. Time Zones
11.2.2.1. Locale
11.2.3. Parsing and Formatting with DateFormat
11.2.4. Printf-Style Date and Time Formatting
11.3. Timers
11.4. Collections
11.4.1. The Collection Interface
11.4.1.1. Generics and collections
11.4.1.2. Runtime versus compile-time safety
11.4.1.3. Collections and arrays
11.4.2. Iteration
11.4.2.1. For-loop over collections
11.4.2.2. java.util.Enumeration
11.4.3. Collection Types
11.4.3.1. Set
11.4.3.2. List
11.4.3.3. Queue
11.4.3.4. BlockingQueue
11.4.4. The Map Interface
11.4.4.1. ConcurrentMap
11.4.5. Collection Implementations
11.4.5.1. Arrays
11.4.5.2. Linked lists
11.4.5.3. Trees
11.4.5.4. Hash maps
11.4.5.5. Java Collections implementations
11.4.6. Hash Codes and Key Values
11.4.7. Synchronized and Unsynchronized Collections
11.4.7.1. Synchronizing iterators
11.4.7.2. ConcurrentHashMap and ConcurrentLinkedQueue
11.4.8. Read-Only and Read-Mostly Collections
11.4.8.1. Copy on write (“read-mostly”) collections
11.4.9. WeakHashMap
11.4.10. EnumSet and EnumMap
11.4.11. Sorting Collections
11.4.12. A Thrilling Example
11.5. Properties
11.5.1. Loading and Storing
11.5.1.1. Storing as XML
11.5.2. System Properties
11.6. The Preferences API
11.6.1. Preferences for Classes
11.6.2. Preferences Storage
11.6.3. Change Notification
11.7. The Logging API
11.7.1. Overview
11.7.1.1. Loggers
11.7.1.2. Handlers
11.7.1.3. Filters
11.7.1.4. Formatters
11.7.2. Logging Levels
11.7.3. A Simple Example
11.7.4. Logging Setup Properties
11.7.5. The Logger
11.7.6. Performance
11.8. Observers and Observables
12. Input/Output Facilities
12.1. Streams
12.1.1. Terminal I/O
12.1.2. Character Streams
12.1.3. Stream Wrappers
12.1.3.1. Data streams
12.1.3.2. Buffered streams
12.1.3.3. PrintWriter and PrintStream
12.1.4. Pipes
12.1.5. Streams from Strings and Back
12.1.6. The rot13InputStream Class
12.2. Files
12.2.1. The java.io.File Class
12.2.1.1. File constructors
12.2.1.2. Path localization
12.2.1.3. File operations
12.2.2. File Streams
12.2.3. RandomAccessFile
12.2.4. Applets and Files
12.3. Serialization
12.3.1. Initialization with readObject()
12.3.2. SerialVersionUID
12.4. Data Compression
12.4.1. Archives and Compressed Data
12.4.2. Decompressing Data
12.5. The NIO Package
12.5.1. Asynchronous I/O
12.5.2. Performance
12.5.3. Mapped and Locked Files
12.5.4. Channels
12.5.5. Buffers
12.5.5.1. Buffer operations
12.5.5.2. Buffer types
12.5.5.3. Byte order
12.5.5.4. Allocating buffers
12.5.6. Character Encoders and Decoders
12.5.6.1. CharsetEncoder and CharsetDecoder
12.5.7. FileChannel
12.5.7.1. Concurrent access
12.5.7.2. File locking
12.5.7.3. Memory-mapped files
12.5.7.4. Direct transfer
12.5.8. Scalable I/O with NIO
13. Network Programming
13.1. Sockets
13.1.1. Clients and Servers
13.1.1.1. Clients
13.1.1.2. Servers
13.1.1.3. Sockets and security
13.1.2. The DateAtHost Client
13.1.3. The TinyHttpd Server
13.1.3.1. Do French web servers speak French?
13.1.3.2. Taming the daemon
13.1.3.3. Room for improvement
13.1.4. Socket Options
13.1.4.1. SO_TIMEOUT
13.1.4.2. TCP_NODELAY
13.1.4.3. SO_LINGER
13.1.4.4. TCP_KEEPALIVE
13.1.4.5. Half-close
13.1.5. Proxies and Firewalls
13.1.5.1. ProxySelector
13.2. Datagram Sockets
13.2.1. The HeartBeat Applet
13.2.1.1. The HeartBeat applet code
13.2.1.2. The Pulse server code
13.2.2. InetAddress
13.3. Simple Serialized Object Protocols
13.3.1. A Simple Object-Based Server
13.3.1.1. Limitations
13.4. Remote Method Invocation
13.4.1. Remote and Nonremote Objects
13.4.1.1. Stubs and skeletons (be gone!)
13.4.1.2. Remote interfaces
13.4.1.3. Exporting remote objects
13.4.1.4. The RMI registry
13.4.2. An RMI Example
13.4.2.1. Running the example
13.4.2.2. Dynamic class loading
13.4.2.3. Passing remote object references
13.4.3. RMI Object Activation
13.4.4. RMI and CORBA
13.5. Scalable I/O with NIO
13.5.1. Selectable Channels
13.5.2. Using Select
13.5.3. LargerHttpd
13.5.4. Nonblocking Client-Side Operations
14. Programming for the Web
14.1. Uniform Resource Locators (URLs)
14.2. The URL Class
14.2.1. Stream Data
14.2.2. Getting the Content as an Object
14.2.3. Managing Connections
14.2.4. Handlers in Practice
14.2.5. Other Handler Frameworks
14.2.6. Writing Content and Protocol Handlers
14.3. Talking to Web Applications
14.3.1. Using the GET Method
14.3.2. Using the POST Method
14.3.3. The HttpURLConnection
14.3.4. SSL and Secure Web Communications
14.3.5. URLs, URNs, and URIs
14.4. Web Services
14.4.1. XML-RPC
14.4.2. WSDL
14.4.3. The Tools
14.4.3.1. Installation and environment
14.4.4. The Temperature Service
15. Web Applications and Web Services
15.1. Web Application Technologies
15.1.1. JSPs
15.1.2. XML
15.1.3. Application Frameworks
15.2. Web Applications
15.2.1. The Servlet Life Cycle
15.2.2. Servlets
15.2.3. The HelloClient Servlet
15.2.3.1. ServletExceptions
15.2.3.2. Content type
15.2.4. The Servlet Response
15.2.5. Servlet Parameters
15.2.5.1. GET, POST, and the “extra path”
15.2.5.2. GET or POST: which one to use?
15.2.6. The ShowParameters Servlet
15.2.6.1. SnoopServlet
15.2.7. User Session Management
15.2.8. The ShowSession Servlet
15.2.9. The ShoppingCart Servlet
15.2.10. Cookies
15.2.11. The ServletContext API
15.3. WAR Files and Deployment
15.3.1. The web.xml File
15.3.2. URL Pattern Mappings
15.3.3. Deploying HelloClient
15.3.3.1. Reloading web apps
15.3.4. Error and Index Pages
15.3.5. Security and Authentication
15.3.6. Assigning Roles to Users
15.3.7. Secure Data Transport
15.3.8. Authenticating Users
15.3.9. Procedural Security
15.4. Servlet Filters
15.4.1. A Simple Filter
15.4.2. A Test Servlet
15.4.3. Declaring and Mapping Filters
15.4.4. Filtering the Servlet Request
15.4.5. Filtering the Servlet Response
15.5. Building WAR Files with Ant
15.5.1. A Development-Oriented Directory Layout
15.5.2. Deploying and Redeploying WARs with Ant
15.6. Implementing Web Services
15.6.1. XML-RPC in Action
15.6.2. Installation and Environment
15.6.3. Defining the Service
15.6.4. Our Echo Service
15.6.5. Data Types
15.6.5.1. Standard types
15.6.5.2. Value data objects
15.6.6. Deploying the Web Service
15.6.7. Using the Service
16. Swing
16.1. Components
16.1.1. Peers and Look-and-Feel
16.1.2. The MVC Framework
16.1.3. Painting
16.1.4. Enabling and Disabling Components
16.1.5. Focus, Please
16.1.6. Other Component Methods
16.1.6.1. Containers
16.1.7. Layout Managers
16.1.8. Insets
16.1.9. Z-Ordering (Stacking Components)
16.1.10. The revalidate() and doLayout() Methods
16.1.11. Managing Components
16.1.12. Listening for Components
16.1.13. Windows and Frames
16.1.14. Other Methods for Controlling Frames
16.1.15. Content Panes
16.2. Events
16.2.1. Event Receivers and Listener Interfaces
16.2.2. Event Sources
16.2.3. Event Delivery
16.2.4. Event Types
16.2.5. The java.awt.event.InputEvent Class
16.2.6. Mouse and Key Modifiers on InputEvents
16.2.6.1. Mouse-wheel events
16.2.7. Focus Events
16.3. Event Summary
16.3.1. Adapter Classes
16.3.2. Dummy Adapters
16.4. The AWT Robot!
16.5. Multithreading in Swing
17. Using Swing Components
17.1. Buttons and Labels
17.2. HTML Text in Buttons and Labels
17.3. Checkboxes and Radio Buttons
17.4. Lists and Combo Boxes
17.5. The Spinner
17.6. Borders
17.7. Menus
17.8. Pop-up Menus
17.9. Component-Managed Pop-ups
17.10. The JScrollPane Class
17.11. The JSplitPane Class
17.12. The JTabbedPane Class
17.13. Scrollbars and Sliders
17.14. Dialogs
17.15. File Selection Dialog
17.16. The Color Chooser
18. More Swing Components
18.1. Text Components
18.1.1. The TextEntryBox Application
18.1.2. Formatted Text
18.1.3. Filtering Input
18.1.3.1. DocumentFilter
18.1.4. Validating Data
18.1.5. Say the Magic Word
18.1.6. Sharing a Data Model
18.1.7. HTML and RTF for Free
18.1.8. Managing Text Yourself
18.2. Focus Navigation
18.2.1. Trees
18.2.2. Nodes and Models
18.2.3. Save a Tree
18.2.4. Tree Events
18.2.5. A Complete Example
18.3. Tables
18.3.1. A First Stab: Freeloading
18.3.2. Round Two: Creating a Table Model
18.3.3. Round Three: A Simple Spreadsheet
18.3.4. Printing JTables
18.4. Desktops
18.5. Pluggable Look-and-Feel
18.5.1. Synth, the Skinnable L&F
18.6. Creating Custom Components
18.6.1. Generating Events
18.6.2. A Dial Component
18.6.3. Model and View Separation
19. Layout Managers
19.1. FlowLayout
19.2. GridLayout
19.3. BorderLayout
19.4. BoxLayout
19.5. CardLayout
19.6. GridBagLayout
19.6.1. The GridBagConstraints Class
19.6.2. Grid Coordinates
19.6.3. The fill Constraint
19.6.4. Spanning Rows and Columns
19.6.5. Weighting
19.6.5.1. Calculating the weights of rows and columns
19.6.6. Anchoring
19.6.7. Padding and Insets
19.6.8. Relative Positioning
19.6.9. Composite Layouts
19.7. Nonstandard Layout Managers
19.8. Absolute Positioning
19.9. SpringLayout
20. Drawing with the 2D API
20.1. The Big Picture
20.2. The Rendering Pipeline
20.3. A Quick Tour of Java 2D
20.3.1. Filling Shapes
20.3.2. Drawing Shape Outlines
20.3.3. Convenience Methods
20.3.4. Drawing Text
20.3.5. Drawing Images
20.3.5.1. Transformations and rendering
20.3.6. The Whole Iguana
20.4. Filling Shapes
20.4.1. Solid Colors
20.4.2. Color Gradients
20.4.3. Textures
20.4.4. Desktop Colors
20.5. Stroking Shape Outlines
20.6. Using Fonts
20.6.1. Font Metrics
20.7. Displaying Images
20.7.1. The Image Class
20.7.2. Image Observers
20.7.2.1. Preloading images
20.7.3. Scaling and Size
20.8. Drawing Techniques
20.8.1. Double Buffering
20.8.2. Limiting Drawing with Clipping
20.8.3. Offscreen Drawing
20.9. Printing
21. Working with Images and Other Media
21.1. Loading Images
21.1.1. ImageObserver
21.1.2. MediaTracker
21.1.3. ImageIcon
21.1.4. ImageIO
21.2. Producing Image Data
21.2.1. Drawing Animations
21.2.2. BufferedImage Anatomy
21.2.3. Color Models
21.2.4. Creating an Image
21.2.5. Updating a BufferedImage
21.3. Filtering Image Data
21.3.1. How ImageProcessor Works
21.3.2. Converting an Image to a BufferedImage
21.3.3. Using the RescaleOp Class
21.3.4. Using the AffineTransformOp Class
21.4. Saving Image Data
21.5. Simple Audio
21.6. Java Media Framework
22. JavaBeans
22.1. What’s a Bean?
22.1.1. How Big Is a Bean?
22.2. The NetBeans IDE
22.2.1. Installing and Running NetBeans
22.2.1.1. Installing our example beans
22.2.1.2. Creating a project and file
22.2.1.3. The NetBeans workspace
22.3. Properties and Customizers
22.4. Event Hookups and Adapters
22.4.1. Taming the Juggler
22.4.1.1. Running the example
22.4.2. Molecular Motion
22.5. Binding Properties
22.5.1. Constraining Properties
22.6. Building Beans
22.6.1. The Dial Bean
22.6.2. Design Patterns for Properties
22.6.2.1. Bean patterns in NetBeans
22.6.3. A (Slightly) More Realistic Example
22.6.3.1. A bean for validating numeric data
22.6.3.2. An invisible multiplier
22.6.3.3. Putting them together
22.7. Limitations of Visual Design
22.8. Serialization Versus Code Generation
22.9. Customizing with BeanInfo
22.9.1. Getting Properties Information
22.9.1.1. Getting events information
22.9.1.2. Supplying icons
22.9.1.3. Creating customizers and property editors
22.10. Hand-Coding with Beans
22.10.1. Bean Instantiation and Type Management
22.10.2. Working with Serialized Beans
22.10.3. Runtime Event Hookups with Reflection
22.10.3.1. Safety implications
22.10.3.2. How it works
22.11. BeanContext and BeanContextServices
22.12. The Java Activation Framework
22.13. Enterprise JavaBeans
23. Applets
23.1. The Politics of Applets
23.2. The JApplet Class
23.2.1. Applet Life Cycle
23.2.2. The Applet Security Sandbox
23.2.2.1. Trusted applets
23.2.3. Getting Applet Resources
23.2.3.1. Applet parameters
23.2.3.2. Applet resources
23.2.3.3. Driving the browser
23.2.3.4. Inter-applet communication
23.2.3.5. Applet persistence and navigation
23.2.3.6. Applets versus standalone applications
23.2.4. Attributes
23.2.5. Parameters
23.2.6. ¿Habla Applet?
23.2.7. The Complete <applet> Tag
23.2.8. Loading Class Files
23.2.9. Packages
23.2.10. appletviewer
23.3. Using the Java Plug-in
23.3.1. What Is the Java Plug-in?
23.3.2. Messy Tags
23.3.2.1. Applets in Internet Explorer
23.3.3. Viewing Plug-in Applets
23.4. Java Web Start
23.5. Using Digital Signatures
23.5.1. Certificates
23.5.1.1. Certificate authority certificates
23.5.1.2. Site certificates
23.5.1.3. User (signer) certificates
23.5.2. The keytool Utility
23.5.2.1. What about Netscape and Internet Explorer?
23.5.2.2. The TestWrite example
23.5.3. Keystores, Keys, and Certificates
23.5.3.1. Public and private keys
23.5.3.2. Certificates
23.5.4. The jarsigner Utility
23.6. Conclusion
24. XML
24.1. A Bit of Background
24.1.1. Text Versus Binary
24.1.2. A Universal Parser
24.1.3. The State of XML
24.1.4. The XML APIs
24.1.5. XML and Web Browsers
24.2. XML Basics
24.2.1. Attributes
24.2.2. XML Documents
24.2.3. Encoding
24.2.4. Namespaces
24.2.5. Validation
24.2.6. HTML to XHTML
24.3. SAX
24.3.1. The SAX API
24.3.1.1. JAXP
24.3.1.2. SAX’s strengths and weaknesses
24.3.2. Building a Model Using SAX
24.3.2.1. Creating the XML file
24.3.2.2. The model
24.3.2.3. The SAXModelBuilder
24.3.2.4. Test drive
24.3.2.5. Limitations and possibilities
24.3.3. XMLEncoder/Decoder
24.3.3.1. Further thoughts
24.4. DOM
24.4.1. The DOM API
24.4.2. Test-Driving DOM
24.4.3. Generating XML with DOM
24.4.4. JDOM
24.5. XPath
24.5.1. Nodes
24.5.2. Predicates
24.5.3. Functions
24.5.4. The XPath API
24.5.5. XMLGrep
24.6. XInclude
24.6.1. Enabling XInclude
24.7. Validating Documents
24.7.1. Using Document Validation
24.7.2. DTDs
24.7.3. XML Schema
24.7.3.1. Simple types
24.7.3.2. Complex types
24.7.3.3. Trang
24.7.4. The Validation API
24.7.4.1. Alternative schema languages
24.8. JAXB and Code Generation
24.8.1. Generating the Model
24.8.1.1. Unmarshaling from XML
24.8.1.2. Marshaling to XML
24.9. Transforming Documents with XSL/XSLT
24.9.1. XSL Basics
24.9.2. Transforming the Zoo Inventory
24.9.3. XSLTransform
24.9.4. XSL in the Browser
24.10. Web Services
24.11. The End of the Book
A. The Eclipse IDE
A.1. The IDE Wars
A.2. Getting Started with Eclipse
A.2.1. Importing the Learning Java Examples
A.3. Using Eclipse
A.3.1. Getting at the Source
A.3.2. The Lay of the Land
A.3.3. Running the Examples
A.3.4. Building the Ant-Based Examples
A.3.5. Loner Examples
A.4. Eclipse Features
A.4.1. Coding Shortcuts
A.4.2. Auto-Correction
A.4.3. Refactoring
A.4.4. Diff’ing Files
A.4.5. Organizing Imports
A.4.6. Formatting Source Code
A.5. Conclusion
B. BeanShell: Simple Java Scripting
B.1. Running BeanShell
B.2. Java Statements and Expressions
B.2.1. Imports
B.3. BeanShell Commands
B.4. Scripted Methods and Objects
B.4.1. Scripting Interfaces and Adapters
B.5. Changing the Classpath
B.6. Learning More . . .
Glossary
Index
About the Authors
Colophon
← Prev
Back
Next →
← Prev
Back
Next →