About the Author |
|
xvii | |
About the Technical Reviewer |
|
xix | |
Acknowledgments |
|
xxi | |
Introduction |
|
xxiii | |
|
Chapter 1 Introduction to Swing |
|
|
1 | (84) |
|
|
2 | (1) |
|
The Simplest Swing Program |
|
|
3 | (4) |
|
|
7 | (2) |
|
Adding Components to a JFrame |
|
|
9 | (4) |
|
|
13 | (2) |
|
|
13 | (1) |
|
|
13 | (1) |
|
|
14 | (1) |
|
|
14 | (1) |
|
|
15 | (55) |
|
|
16 | (5) |
|
|
21 | (3) |
|
|
24 | (2) |
|
|
26 | (5) |
|
|
31 | (2) |
|
|
33 | (18) |
|
|
51 | (8) |
|
|
59 | (9) |
|
|
68 | (2) |
|
Creating a Reusable JFrame |
|
|
70 | (2) |
|
|
72 | (7) |
|
|
79 | (3) |
|
|
82 | (3) |
|
Chapter 2 Swing Components |
|
|
85 | (120) |
|
What Is a Swing Component? |
|
|
85 | (5) |
|
|
90 | (5) |
|
|
95 | (1) |
|
|
96 | (1) |
|
|
97 | (30) |
|
|
100 | (2) |
|
|
102 | (5) |
|
|
107 | (1) |
|
|
108 | (3) |
|
|
111 | (3) |
|
|
114 | (5) |
|
|
119 | (8) |
|
|
127 | (1) |
|
|
128 | (9) |
|
|
137 | (2) |
|
|
139 | (1) |
|
|
140 | (2) |
|
|
142 | (1) |
|
|
143 | (2) |
|
|
145 | (1) |
|
|
145 | (8) |
|
|
153 | (3) |
|
JToolBar Meets the Action Interface |
|
|
156 | (1) |
|
|
157 | (6) |
|
|
163 | (6) |
|
JTabbedPane and JSplitPane |
|
|
169 | (2) |
|
|
171 | (3) |
|
|
174 | (7) |
|
|
181 | (5) |
|
|
181 | (4) |
|
|
185 | (1) |
|
|
186 | (1) |
|
|
186 | (1) |
|
|
187 | (3) |
|
|
190 | (2) |
|
|
192 | (1) |
|
Painting Components and Drawing Shapes |
|
|
193 | (5) |
|
|
198 | (1) |
|
|
198 | (2) |
|
|
200 | (2) |
|
|
202 | (3) |
|
|
205 | (48) |
|
Using HTML in Swing Components |
|
|
206 | (1) |
|
|
207 | (8) |
|
|
215 | (6) |
|
|
221 | (8) |
|
Multiple Document Interface Application |
|
|
229 | (3) |
|
|
232 | (2) |
|
Decorating Components Using JLayer |
|
|
234 | (7) |
|
|
241 | (6) |
|
|
247 | (3) |
|
|
250 | (3) |
|
Chapter 4 Network Programming |
|
|
253 | (94) |
|
What Is Network Programming? |
|
|
253 | (2) |
|
|
255 | (3) |
|
|
258 | (4) |
|
|
258 | (3) |
|
|
261 | (1) |
|
|
262 | (3) |
|
|
262 | (1) |
|
|
263 | (1) |
|
|
264 | (1) |
|
|
264 | (1) |
|
|
264 | (1) |
|
|
265 | (1) |
|
|
265 | (1) |
|
Socket API and Client-Server Paradigm |
|
|
266 | (4) |
|
|
268 | (1) |
|
|
268 | (1) |
|
|
269 | (1) |
|
|
269 | (1) |
|
|
269 | (1) |
|
The Send/Sendto Primitive |
|
|
270 | (1) |
|
The Receive/ReceiveFrom Primitive |
|
|
270 | (1) |
|
|
270 | (1) |
|
Representing a Machine Address |
|
|
270 | (3) |
|
Representing a Socket Address |
|
|
273 | (1) |
|
Creating a TCP Server Socket |
|
|
274 | (4) |
|
Creating a TCP Client Socket |
|
|
278 | (2) |
|
Putting a TCP Server and Clients Together |
|
|
280 | (1) |
|
|
281 | (3) |
|
Creating a UDP Echo Server |
|
|
284 | (4) |
|
|
288 | (1) |
|
|
289 | (3) |
|
|
292 | (3) |
|
URI and URL as Java Objects |
|
|
295 | (4) |
|
Accessing the Contents of a URL |
|
|
299 | (7) |
|
Non-Blocking Socket Programming |
|
|
306 | (12) |
|
Socket Security Permissions |
|
|
318 | (1) |
|
Asynchronous Socket Channels |
|
|
319 | (13) |
|
Setting Up an Asynchronous Server Socket Channel |
|
|
320 | (7) |
|
Setting Up an Asynchronous Client Socket Channel |
|
|
327 | (3) |
|
Putting the Server and the Client Together |
|
|
330 | (2) |
|
Datagram-Oriented Socket Channels |
|
|
332 | (5) |
|
Creating the Datagram Channel |
|
|
332 | (1) |
|
Setting the Channel Options |
|
|
332 | (2) |
|
|
334 | (3) |
|
Multicasting Using Datagram Channels |
|
|
337 | (6) |
|
Creating the Datagram Channel |
|
|
337 | (1) |
|
Setting the Channel Options |
|
|
337 | (1) |
|
|
337 | (1) |
|
Setting the Multicast Network Interface |
|
|
338 | (1) |
|
Joining the Multicast Group |
|
|
339 | (1) |
|
|
340 | (1) |
|
|
340 | (3) |
|
|
343 | (1) |
|
|
343 | (4) |
|
|
347 | (142) |
|
|
348 | (1) |
|
|
348 | (1) |
|
|
349 | (1) |
|
|
349 | (1) |
|
|
349 | (1) |
|
|
350 | (1) |
|
A Brief Overview of Apache Derby |
|
|
350 | (5) |
|
|
350 | (1) |
|
|
350 | (1) |
|
|
350 | (1) |
|
|
351 | (1) |
|
|
351 | (4) |
|
Creating a Database Table |
|
|
355 | (2) |
|
|
356 | (1) |
|
Adaptive Server Anywhere Database |
|
|
356 | (1) |
|
|
356 | (1) |
|
|
356 | (1) |
|
|
357 | (1) |
|
|
357 | (1) |
|
|
357 | (12) |
|
Obtaining the JDBC Driver |
|
|
357 | (1) |
|
Setting Up the Module Path |
|
|
358 | (1) |
|
Registering a JDBC Driver |
|
|
358 | (2) |
|
Constructing a Connection URL |
|
|
360 | (4) |
|
Establishing the Database Connection |
|
|
364 | (5) |
|
Setting the Auto-Commit Mode |
|
|
369 | (1) |
|
Committing and Rolling Back Transactions |
|
|
369 | (1) |
|
Transaction Isolation Level |
|
|
370 | (2) |
|
|
370 | (1) |
|
|
370 | (1) |
|
|
371 | (1) |
|
JDBC-Types-to-Java-Types Mapping |
|
|
372 | (3) |
|
Knowing About the Database |
|
|
375 | (2) |
|
|
377 | (25) |
|
Results of Executing a SQL Statement |
|
|
378 | (1) |
|
Using the Statement Interface |
|
|
379 | (7) |
|
Using the PreparedStatement Interface |
|
|
386 | (3) |
|
CallableStatement Interface |
|
|
389 | (13) |
|
|
402 | (19) |
|
|
402 | (4) |
|
|
406 | (6) |
|
Getting the Number of Rows in a ResultSet |
|
|
412 | (3) |
|
Bidirectional Scrollable ResultSets |
|
|
415 | (2) |
|
Scrolling Through Rows of a ResultSet |
|
|
417 | (3) |
|
Knowing the Cursor Position in a ResultSet |
|
|
420 | (1) |
|
|
420 | (1) |
|
Making Changes to a ResultSet |
|
|
421 | (5) |
|
Inserting a Row Using a ResultSet |
|
|
421 | (2) |
|
Updating a Row Using a ResultSet |
|
|
423 | (3) |
|
Deleting a Row Using a ResultSet |
|
|
426 | (1) |
|
Handling Multiple Results from a Statement |
|
|
426 | (2) |
|
Getting a Result Set from a Stored Procedure |
|
|
428 | (7) |
|
|
429 | (1) |
|
Adaptive Server Anywhere Database |
|
|
429 | (1) |
|
|
429 | (1) |
|
|
430 | (1) |
|
|
430 | (1) |
|
|
431 | (4) |
|
|
435 | (2) |
|
|
437 | (25) |
|
|
440 | (22) |
|
Working with a Large Object (LOB) |
|
|
462 | (10) |
|
|
464 | (1) |
|
|
465 | (7) |
|
|
472 | (6) |
|
Savepoints in a Transaction |
|
|
478 | (3) |
|
|
481 | (2) |
|
|
483 | (1) |
|
|
484 | (1) |
|
|
484 | (5) |
|
Chapter 6 Java Remote Method Invocation |
|
|
489 | (26) |
|
What Is Java Remote Method Invocation? |
|
|
490 | (1) |
|
|
491 | (2) |
|
Developing an RMI Application |
|
|
493 | (7) |
|
Writing the Remote Interface |
|
|
493 | (1) |
|
Implementing the Remote Interface |
|
|
494 | (2) |
|
Writing the RMI Server Program |
|
|
496 | (3) |
|
Writing the RMI Client Program |
|
|
499 | (1) |
|
Separating the Server and Client Code |
|
|
500 | (1) |
|
Generating Stub and Skeleton |
|
|
500 | (1) |
|
Running the RMI Application |
|
|
501 | (3) |
|
|
502 | (1) |
|
|
503 | (1) |
|
Running an RMI Client Program |
|
|
503 | (1) |
|
Troubleshooting an RMI Application |
|
|
504 | (3) |
|
java.rmi.StubNotFoundException |
|
|
504 | (1) |
|
java.rmi.server.ExportException |
|
|
505 | (1) |
|
java.security.AccessControlException |
|
|
505 | (1) |
|
java.lang.ClassNotFoundException |
|
|
506 | (1) |
|
Debugging an RMI Application |
|
|
507 | (1) |
|
Dynamic Class Downloading |
|
|
508 | (1) |
|
Garbage Collection of Remote Objects |
|
|
509 | (3) |
|
|
512 | (3) |
|
Chapter 7 Java Native Interface |
|
|
515 | (46) |
|
What Is the Java Native Interface? |
|
|
515 | (1) |
|
|
516 | (1) |
|
Getting Started with the JNI |
|
|
517 | (11) |
|
|
517 | (4) |
|
Compiling the Java Program |
|
|
521 | (1) |
|
Creating the C/C++ Header File |
|
|
521 | (2) |
|
Writing the C/C++ Program |
|
|
523 | (1) |
|
Creating a Shared Library |
|
|
524 | (3) |
|
|
527 | (1) |
|
Native Function Naming Rules |
|
|
528 | (3) |
|
|
531 | (1) |
|
Using JNI Functions in C/C++ |
|
|
532 | (1) |
|
|
533 | (3) |
|
|
536 | (4) |
|
Accessing Java Objects in Native Code |
|
|
540 | (9) |
|
Getting a Class Reference |
|
|
540 | (1) |
|
Accessing Fields and Methods of a Java Object/Class |
|
|
541 | (6) |
|
|
547 | (2) |
|
|
549 | (3) |
|
Handle the Exception in Native Code |
|
|
550 | (1) |
|
Handling the Exception in Java Code |
|
|
551 | (1) |
|
Throwing a New Exception from Native Code |
|
|
551 | (1) |
|
Creating an Instance of the JVM |
|
|
552 | (5) |
|
Synchronization in Native Code |
|
|
557 | (1) |
|
|
558 | (3) |
|
Chapter 8 Introduction to JavaFX |
|
|
561 | (90) |
|
|
561 | (2) |
|
|
563 | (1) |
|
|
564 | (1) |
|
|
564 | (1) |
|
|
565 | (1) |
|
|
565 | (1) |
|
Your First JavaFX Application |
|
|
565 | (7) |
|
Creating the HelloJavaFX Class |
|
|
565 | (1) |
|
Overriding the start() Method |
|
|
566 | (1) |
|
|
567 | (1) |
|
Launching the Application |
|
|
568 | (2) |
|
|
570 | (1) |
|
Adding a Scene to the Stage |
|
|
570 | (2) |
|
Improving Your First JavaFX Application |
|
|
572 | (2) |
|
The Lifecycle of a JavaFX Application |
|
|
574 | (2) |
|
Terminating a JavaFX Application |
|
|
576 | (1) |
|
What Are Properties and Bindings? |
|
|
576 | (1) |
|
Properties and Bindings in JavaFX |
|
|
577 | (18) |
|
Using Properties in JavaFX Beans |
|
|
580 | (4) |
|
Handling Property Invalidation Events |
|
|
584 | (2) |
|
Handling Property Change Events |
|
|
586 | (3) |
|
Property Bindings in JavaFX |
|
|
589 | (6) |
|
|
595 | (3) |
|
|
598 | (9) |
|
Event Processing Mechanism |
|
|
599 | (3) |
|
Creating Event Filters and Handlers |
|
|
602 | (1) |
|
Registering Event Filters and Handlers |
|
|
603 | (4) |
|
|
607 | (7) |
|
|
614 | (6) |
|
|
620 | (4) |
|
|
624 | (2) |
|
|
626 | (3) |
|
|
629 | (3) |
|
|
632 | (5) |
|
Using the Timeline Animation |
|
|
634 | (3) |
|
|
637 | (5) |
|
|
642 | (5) |
|
|
647 | (4) |
|
Chapter 9 Scripting in Java |
|
|
651 | (84) |
|
What Is Scripting in Java? |
|
|
651 | (2) |
|
Executing Your First Script |
|
|
653 | (2) |
|
Using Other Scripting Languages |
|
|
655 | (3) |
|
Exploring the javax.script Package |
|
|
658 | (2) |
|
The ScriptEngine and ScriptEngineFactory Interfaces |
|
|
658 | (1) |
|
The AbstractScriptEngine Class |
|
|
658 | (1) |
|
The ScriptEngineManager Class |
|
|
658 | (1) |
|
The Compilable Interface and the CompiledScript Class |
|
|
658 | (1) |
|
|
658 | (1) |
|
The Bindings Interface and the SimpleBindings Class |
|
|
659 | (1) |
|
The ScriptContext Interface and the SimpleScriptContext Class |
|
|
659 | (1) |
|
The ScriptException Class |
|
|
659 | (1) |
|
Discovering and Instantiating Script Engines |
|
|
659 | (1) |
|
|
660 | (2) |
|
|
662 | (3) |
|
Passing Parameters from Java Code to Scripts |
|
|
662 | (2) |
|
Passing Parameters from Scripts to Java Code |
|
|
664 | (1) |
|
Advanced Parameter Passing Techniques |
|
|
665 | (12) |
|
|
665 | (1) |
|
|
666 | (1) |
|
Defining the Script Context |
|
|
667 | (4) |
|
|
671 | (6) |
|
Using a Custom ScriptContext |
|
|
677 | (3) |
|
Return Value of the eval() Method |
|
|
680 | (1) |
|
Reserved Keys for Engine Scope Bindings |
|
|
681 | (1) |
|
Changing the Default ScriptContext |
|
|
682 | (1) |
|
Sending Script Output to a File |
|
|
683 | (1) |
|
Invoking Procedures in Scripts |
|
|
684 | (3) |
|
Implementing Java Interfaces in Scripts |
|
|
687 | (4) |
|
|
691 | (2) |
|
Using Java in Scripting Languages |
|
|
693 | (14) |
|
|
694 | (1) |
|
|
694 | (3) |
|
Creating and Using Java Objects |
|
|
697 | (1) |
|
Using Overloaded Java Methods |
|
|
698 | (2) |
|
|
700 | (3) |
|
Extending Java Classes and Implementing Interfaces |
|
|
703 | (3) |
|
|
706 | (1) |
|
Implementing a Script Engine |
|
|
707 | (12) |
|
|
708 | (5) |
|
|
713 | (2) |
|
The JKScriptEngineFactory Class |
|
|
715 | (1) |
|
Packaging the JKScript Files |
|
|
716 | (1) |
|
Using the JKScript Script Engine |
|
|
717 | (2) |
|
The jrunscript Command-Line Shell |
|
|
719 | (5) |
|
|
719 | (2) |
|
Execution Modes of the Shell |
|
|
721 | (1) |
|
Listing Available Script Engines |
|
|
722 | (1) |
|
Adding a Script Engine to the Shell |
|
|
722 | (1) |
|
Using Other Script Engines |
|
|
723 | (1) |
|
Passing Arguments to Scripts |
|
|
723 | (1) |
|
The jjs Command-Line Tool |
|
|
724 | (5) |
|
|
729 | (3) |
|
|
732 | (3) |
|
|
735 | (28) |
|
|
735 | (2) |
|
Knowing the Runtime Environment |
|
|
737 | (1) |
|
|
738 | (1) |
|
|
739 | (3) |
|
|
742 | (1) |
|
|
743 | (12) |
|
Obtaining a Process Handle |
|
|
755 | (2) |
|
|
757 | (1) |
|
Managing Process Permissions |
|
|
758 | (2) |
|
|
760 | (3) |
|
Chapter 11 Packaging Modules |
|
|
763 | (20) |
|
|
763 | (11) |
|
What Is a Multi-Release JAR? |
|
|
764 | (1) |
|
Creating Multi-Release JARs |
|
|
765 | (6) |
|
Rules for Multi-Release JARs |
|
|
771 | (2) |
|
Multi-Release JARs and JAR URL |
|
|
773 | (1) |
|
Multi-Release Manifest Attribute |
|
|
773 | (1) |
|
|
774 | (6) |
|
|
774 | (6) |
|
|
780 | (3) |
|
Chapter 12 Custom Runtime Images |
|
|
783 | (14) |
|
What Is a Custom Runtime Image? |
|
|
783 | (1) |
|
|
784 | (1) |
|
Creating Custom Runtime Images |
|
|
784 | (4) |
|
|
788 | (2) |
|
Using Plugins with the jlink Tool |
|
|
790 | (3) |
|
|
793 | (2) |
|
|
795 | (2) |
Index |
|
797 | |