Cover image for Beginning Java 2 : JDK 1.3 edition
Title:
Beginning Java 2 : JDK 1.3 edition
Author:
Horton, Ivor.
Personal Author:
Publication Information:
Birmingham, UK : Wrox Press, [2000]

©2000
Physical Description:
xxv, 1233 pages : illustrations ; 24 cm.
General Note:
Includes index.
Language:
English
ISBN:
9781861003669
Format :
Book

Available:*

Library
Call Number
Material Type
Home Location
Status
Central Library QA76.76.J38 H6736 2000 Adult Non-Fiction Central Closed Stacks
Searching...

On Order

Summary

Summary

A second edition Beginning Java title is now required because: In quarter one, 2000, Sun will release version 1.3 of their Java Developers Kit (JDK 1.3). This is significant because: The fastest Java platform performance ever is now available for download, and is coming to your mailbox from America Online (AOL), thanks to an agreement between Sun and AOL to deliver the Java Runtime Environment on the AOL 5.0 CD-ROM. The newest version of J2SE technology, v 1.3, will deliver momentous performance gains and improved Web deployment for enterprise-grade, client-side applications. And just about everything else developers have been asking for: Client-side users now enjoy the speed advantage of the new Java HotSpot compiler which has been tuned for client performance. The result is much faster thread handling, improved scalability and rapid memory allocation for objects, smaller RAM footprint, and the platform has gained a much more efficient garbage collector. All of these enhancements spell speed for the desktop user. For Graphical User Interface (GUI) performance, the Java Foundation Classes and Swing libraries have been super-tuned to enhance scrolling speed. The GUI components that


Table of Contents

Introductionp. 1
Chapter 1 Introducing Javap. 7
What is Java All About?p. 7
Learning Javap. 8
Java Programsp. 9
Learning Java - the Road Aheadp. 9
The Java Environmentp. 10
Java Program Developmentp. 11
The Hypertext Markup Languagep. 14
Object-Oriented Programming in Javap. 18
So What Are Objects?p. 19
What Defines a Class of Objects?p. 20
Java Program Structurep. 25
Java's Class Libraryp. 26
Java Applicationsp. 28
Java and Unicodep. 30
Summaryp. 30
Resourcesp. 31
Chapter 2 Programs, Data, Variables and Calculationp. 33
Data and Variablesp. 33
Variable Namesp. 34
Integer Data Typesp. 35
Integer Valuesp. 37
Declaring Integer Variablesp. 38
Floating Point Data Typesp. 39
Floating Point Valuesp. 40
Declaring Floating Point Variablesp. 40
Arithmetic Calculationsp. 41
Integer Calculationsp. 42
Integer Division and Remaindersp. 46
The Increment and Decrement Operatorsp. 46
Computation with Shorter Integer Typesp. 48
Floating Point Calculationsp. 49
Mixed Arithmetic Expressionsp. 51
Explicit Castingp. 51
Casting in Assignmentsp. 52
The op= Operatorsp. 52
Mathematical Functions and Constantsp. 53
Storing Charactersp. 56
Character Escape Sequencesp. 56
Character Arithmeticp. 57
Bitwise Operationsp. 58
Shift Operationsp. 62
Boolean Variablesp. 63
Operator Precedencep. 64
Program Commentsp. 65
Summaryp. 67
Exercisesp. 68
Chapter 3 Loops and Logicp. 71
Making Decisionsp. 71
Making Comparisonsp. 72
The if Statementp. 73
Nested if Statementsp. 76
Logical Operatorsp. 79
The Conditional Operatorp. 84
The switch Statementp. 85
Variable Scopep. 88
Loopsp. 90
Nested Loopsp. 97
The continue Statementp. 99
Using the break Statement in a Loopp. 101
Summaryp. 106
Exercisesp. 107
Chapter 4 Arrays and Stringsp. 109
Arraysp. 109
Array Variablesp. 110
Defining an Arrayp. 110
Accessing Array Elementsp. 112
Reusing Array Variablesp. 112
Initializing Arraysp. 113
Using Arraysp. 115
Arrays of Arraysp. 118
Arrays of Charactersp. 122
Using Stringsp. 122
String Literalsp. 123
Creating String Objectsp. 123
Arrays of Stringsp. 125
Operations on Stringsp. 126
Joining Stringsp. 126
Comparing Stringsp. 130
Sequencing Stringsp. 134
Accessing String Charactersp. 136
Searching Strings for Charactersp. 138
Searching for Substringsp. 139
Extracting Substringsp. 142
Modifying String Objectsp. 145
Creating Character Arrays from String Objectsp. 145
Creating String Objects from Character Arraysp. 146
StringBuffer Objectsp. 147
Creating StringBuffer Objectsp. 147
The Capacity of a StringBuffer Objectp. 148
Changing the Length for a StringBuffer Objectp. 149
Adding to a StringBuffer Objectp. 150
Inserting Stringsp. 152
Extracting Characters from a StringBuffer Objectp. 153
Other StringBuffer Operationsp. 153
Creating a String Object from a StringBuffer Objectp. 154
Summaryp. 154
Exercisesp. 155
Chapter 5 Defining Classesp. 159
What is a Class?p. 159
Variables in a Class Definitionp. 160
Methods in a Class Definitionp. 162
Accessing Variables and Methodsp. 163
Defining Classesp. 164
Defining Methodsp. 165
Returning from a Methodp. 166
The Parameter Listp. 166
Defining Class Methodsp. 168
Accessing Class Data Members in a Methodp. 168
The Variable thisp. 169
Initializing Data Membersp. 170
Constructorsp. 173
Creating Objects of a Classp. 175
Defining and Using a Classp. 177
Method Overloadingp. 179
Multiple Constructorsp. 180
Duplicating Objects Using a Constructorp. 182
Using Objectsp. 183
Creating a Point from Two Linesp. 187
Recursionp. 190
Understanding Packagesp. 193
Packaging up Your Classesp. 193
Adding Classes from a Package to your Programp. 197
Packages and Names in your Programsp. 197
Standard Packagesp. 198
Controlling Access to Class Membersp. 199
Using Access Attributesp. 200
Specifying Access Attributesp. 201
Choosing Access Attributesp. 203
Nested Classesp. 208
Static Nested Classesp. 210
Using a Non-Static Nested Classp. 214
Using a Nested Class outside the Top-Level Classp. 215
Local Nested Classesp. 217
The finalize() Methodp. 217
Native Methodsp. 218
Summaryp. 218
Exercisesp. 219
Chapter 6 Extending Classes and Inheritancep. 221
Using Existing Classesp. 222
Class Inheritancep. 223
Inheriting Data Membersp. 224
Inherited Methodsp. 225
Overriding a Base Class Methodp. 229
Choosing Base Class Access Attributesp. 230
Polymorphismp. 231
Using Polymorphismp. 233
Multiple Levels of Inheritancep. 237
Abstract Classesp. 238
The Universal Superclassp. 239
The toString() Methodp. 240
Determining the Type of an Objectp. 241
Members of the class Classp. 241
Copying Objectsp. 243
Casting Objectsp. 248
When to Cast Objectsp. 250
Identifying Objectsp. 251
Designing Classesp. 252
A Classy Examplep. 253
Using the final Modifierp. 264
Interfacesp. 265
Implementing an Interfacep. 267
Using Interfacesp. 270
Nesting Classes in an Interface Definitionp. 274
Anonymous Classesp. 275
Summaryp. 276
Exercisesp. 277
Chapter 7 Exceptionsp. 279
The Idea Behind Exceptionsp. 279
Types of Exceptionsp. 280
Error Exceptionsp. 281
RuntimeException Exceptionsp. 282
Other Subclasses of Exceptionp. 283
Dealing with Exceptionsp. 284
Specifying the Exceptions a Method Can Throwp. 284
Handling Exceptionsp. 285
The try Blockp. 285
The catch Blockp. 285
The finally Blockp. 291
Structuring a Methodp. 291
Execution Sequencep. 293
Nested try Blocksp. 298
Rethrowing Exceptionsp. 299
Exception Objectsp. 300
The Class Throwablep. 300
Defining your own Exceptionsp. 303
Defining an Exception Classp. 303
Throwing your Own Exceptionp. 304
An Exception Handling Strategyp. 305
Summaryp. 309
Exercisesp. 310
Chapter 8 Streams, Files and Stream Outputp. 313
Understanding Streamsp. 313
Stream Input/Output Operationsp. 315
The Classes for Input and Outputp. 316
Defining a Filep. 317
Testing and Checking File Objectsp. 318
Accessing File Objectsp. 320
Modifying File Objects and Filesp. 326
Byte Output Streamsp. 327
Subclasses of OutputStreamp. 328
The FileOutputStream Classp. 329
The ByteArrayOutputStream Classp. 331
The PipedOutputStream Classp. 332
The FilterOutputStream Classesp. 333
The DataOutputStream Classp. 335
Buffered Output Streamsp. 338
Writing a Compressed Filep. 341
Character Output Streamsp. 344
Writing Characters to an Array or a String Bufferp. 346
Connecting a Character Stream to a Byte Streamp. 347
Using a Character Stream to Write a Filep. 348
Formatting Printed Outputp. 352
Summaryp. 356
Exercisesp. 357
Chapter 9 Stream Input, and Object Streamsp. 359
Byte Input Streamsp. 359
Sub-classes of InputStreamp. 361
The FileInputStream Objectp. 362
Sequence Input Streamsp. 362
The Input Filter Classesp. 364
Reading from an Input Streamp. 365
Reading from a Disk Filep. 365
Reading a ZIP Archivep. 368
Character Input Streamsp. 370
Reading a File as a Character Streamp. 372
Formatted Stream Inputp. 375
Random Access Filesp. 380
Input and Output Operationsp. 380
Changing the File Positionp. 381
Using Random Access Filesp. 381
Storing Objects in a Filep. 386
Writing an Object to a Filep. 387
Implementing the Serializable Interfacep. 388
Reading an Object from a Filep. 389
Using Object Serializationp. 391
Serializing Classes Yourselfp. 393
Summaryp. 395
Exercisesp. 396
Chapter 10 Utility Classesp. 399
Understanding the Utility Classesp. 400
Collections of Objectsp. 400
Setsp. 401
Sequencesp. 401
Mapsp. 402
Iteratorsp. 403
Collection Classesp. 407
Collection Interfacesp. 408
Using a Vector Collectionp. 409
Creating a Vectorp. 409
Storing Objects in a Vectorp. 412
Retrieving Objects from a Vectorp. 413
Removing Objects from a Vectorp. 416
Searching a Vectorp. 417
Using Vectorsp. 418
Sortingp. 423
Stack Storagep. 425
Linked Listsp. 431
Using Mapsp. 433
The Hashing Processp. 433
Using Your Own Class Objects as Keysp. 434
Creating a HashMapp. 435
Storing, Retrieving and Removing Objectsp. 436
Processing all the Elements in a Mapp. 437
Observable and Observer Objectsp. 447
Defining Classes of Observable Objectsp. 448
Observable Class Methodsp. 449
Generating Random Numbersp. 452
Random Operationsp. 453
Dates and Timesp. 455
The Date Classp. 456
Interpreting Date Objectsp. 456
Gregorian Calendarsp. 460
Summaryp. 464
Exercisesp. 465
Chapter 11 Threadsp. 467
Understanding Threadsp. 467
Creating Threadsp. 470
Stopping a Threadp. 474
Thread Schedulingp. 477
Implementing the Runnable Interfacep. 478
Managing Threadsp. 480
Synchronizationp. 480
Deadlocksp. 499
Communicating between Threadsp. 501
Thread Prioritiesp. 506
Using Thread Prioritiesp. 507
Summaryp. 509
Exercisesp. 511
Chapter 12 Creating Windowsp. 513
Graphical User Interfaces in Javap. 513
Model-View-Controller (MVC) Architecturep. 514
Creating a Windowp. 516
Components and Containersp. 519
Window and Frame Componentsp. 520
Window Panesp. 521
Basics of Componentsp. 523
Visual Characteristics of a Componentp. 530
Swing Componentsp. 539
Using Containersp. 542
Adding Components to a Containerp. 544
Container Layout Managersp. 545
The Flow Layout Managerp. 546
Using a Border Layout Managerp. 550
Using a Card Layout Managerp. 553
Using a Grid Layout Managerp. 555
Using a BoxLayout Managerp. 556
Using a GridBaglayout Managerp. 564
Adding a Menu to a Windowp. 571
Creating JMenu and JMenuItemp. 571
Creating a Menup. 572
Adding Items to a Pull-Down Menup. 574
More on Appletsp. 581
Converting an Application to an Appletp. 582
Summaryp. 584
Exercisesp. 585
Chapter 13 Handling Eventsp. 587
Window-based Java Programsp. 588
Event-driven Programsp. 588
The Event-handling Processp. 589
Event Classesp. 590
Low-level Event Classesp. 591
Low-level Event Listenersp. 598
Semantic Eventsp. 604
Semantic Event Listenersp. 605
Semantic Event Handling in Appletsp. 605
Handling Low-level and Semantic Eventsp. 616
Semantic Event Listeners in an Applicationp. 618
Listening to Menu Itemsp. 618
Using Actionsp. 623
The Action Interfacep. 624
Using Actions as Menu Itemsp. 625
Adding a Toolbarp. 632
Adding Buttons to a Toolbarp. 632
Adding Tooltipsp. 639
Disabling Actionsp. 642
Summaryp. 643
Exercisesp. 643
Chapter 14 Drawing in a Windowp. 647
Using the Model/View Architecturep. 647
Coordinate Systems in Componentsp. 651
Drawing on a Componentp. 652
Graphics Contextsp. 653
The Drawing Processp. 656
Rendering Operationsp. 657
Shapesp. 657
Classes Defining Pointsp. 658
Lines and Rectanglesp. 660
Arcs and Ellipsesp. 665
Curvesp. 668
Complex Pathsp. 677
Filling Shapesp. 683
Gradient Fillp. 684
Managing Shapesp. 688
Storing Shapes in the Documentp. 689
Drawing Shapesp. 691
Drawing Using the Mousep. 692
Handling Mouse Eventsp. 692
Handling Mouse Button Press Eventsp. 695
Handling Mouse Dragging Eventsp. 696
Handling Button Release Eventsp. 699
Defining Our Own Shape Classesp. 700
Defining Linesp. 700
Defining Rectanglesp. 703
Defining Circlesp. 705
Drawing Curvesp. 707
Summaryp. 709
Exercisesp. 710
Chapter 15 Extending the GUIp. 713
Creating a Status Barp. 713
Using Dialogsp. 718
Modal and Non-modal Dialogsp. 719
A Simple Modal Dialogp. 720
Instant Dialogsp. 724
Input Dialogsp. 726
A Font Selection Dialogp. 736
Pop-up Menusp. 751
Displaying a Pop-up Menup. 752
Implementing a Context Menup. 755
Transforming the User Coordinate Systemp. 764
The AffineTransform Classp. 766
Modifying the Transformation for a Graphics Contextp. 767
Creating AffineTransform Objectsp. 768
Choosing Custom Colorsp. 785
Summaryp. 787
Exercisesp. 788
Chapter 16 Filing and Printing Documentsp. 791
Serializing the Sketchp. 792
Implementing the Serializable Interfacep. 795
Serializing the List of Elementsp. 795
Supporting the File Menup. 801
Using a File Chooserp. 802
File Save Operationsp. 803
File Save As Operationsp. 811
File Open Operationsp. 812
Starting a New Sketchp. 815
Preventing Data Loss on Closep. 815
Printing in Javap. 817
Creating and Using PrinterJob Objectsp. 819
Printing Pagesp. 821
Printing the Whole Sketchp. 826
Printing in Landscape Orientationp. 831
Multi-Page Printingp. 834
Printing Using a Bookp. 843
Printing Componentsp. 845
Summaryp. 848
Exercisesp. 849
Chapter 17 Images and Animationp. 851
Applet Operationsp. 851
HTML for Appletsp. 853
Obtaining an Imagep. 854
Identifying Sources on a Networkp. 856
Displaying an Imagep. 860
Creating Image Objectsp. 862
Animationp. 867
An Animated Appletp. 868
Transforming Imagesp. 876
Using Timersp. 881
Alpha Compositingp. 897
The AlphaComposite Classp. 898
Synthesizing Imagesp. 905
Creating an Imagep. 906
Summaryp. 917
Exercisesp. 918
Chapter 18 Adding Sound to your Programsp. 921
Some Sound Conceptsp. 921
Digital Sound Qualityp. 923
Simple Sound Outputp. 929
Simple Sounds in an Applicationp. 931
Sound API Basicsp. 935
Sound System Resourcesp. 935
Sampled Sound Interfacesp. 937
Accessing Sound Devicesp. 941
Playing Soundsp. 946
Creating an Audio Streamp. 947
Accessing a Clipp. 949
Playing a Clipp. 950
Another Approach to Playing a Sound Filep. 957
Sound Recordingp. 967
Establishing the Recording Inputp. 967
Recording the Datap. 968
Sound Eventsp. 976
Understanding MIDIp. 977
Working with Midip. 979
MIDI Resourcesp. 979
Playing a MIDI Filep. 982
Using a Synthesizerp. 986
Summaryp. 994
Exercisesp. 995
Chapter 19 Talking to Databasesp. 997
JDBC Concepts and Terminologyp. 998
Tablesp. 999
Database Catalogp. 1001
Introducing SQLp. 1002
SQL Statementsp. 1007
Select Statementsp. 1010
Update Statementsp. 1012
Delete Statementsp. 1013
The JDBC Packagep. 1013
Relating JDBC to ODBCp. 1014
JDBC Basicsp. 1014
Setting up a Databasep. 1015
DriverManagerp. 1016
Creating a Connection to a Data Sourcep. 1018
More on Driversp. 1022
Statement Objectsp. 1025
ResultSet Objectsp. 1026
Getting Metadata for a Resultsetp. 1030
The Essential JDBC Programp. 1032
Using a PreparedStatement Objectp. 1036
The InteractiveSQL Toolp. 1040
Using Tablesp. 1041
The Application GUIp. 1045
Handling Command Line Argumentsp. 1049
Handling Eventsp. 1050
Summaryp. 1053
Exercisesp. 1054
Chapter 20 The JDBC in Actionp. 1057
Data Types and JDBCp. 1057
Mapping between Java and SQL Data Typesp. 1057
Mapping Relational Data onto Java Objectsp. 1059
A Better Mapping Strategyp. 1064
The Statement and PreparedStatement Interfacesp. 1067
The Statement Interfacep. 1067
The PreparedStatement Interfacep. 1074
The ResultSetp. 1079
Retrieving Column Data for Specified Data Typesp. 1079
Calling Proceduresp. 1086
Handling Errorsp. 1088
SQLExceptionp. 1088
Chaining SQLExceptionsp. 1093
SQLWarningsp. 1096
Browsing a Databasep. 1098
Displaying Database Datap. 1102
Using a JTree Componentp. 1103
Getting Database Metadatap. 1107
Using Tree Listenersp. 1116
Summaryp. 1121
Exercisesp. 1122
Appendix A Java Archives--JAR filesp. 1125
The JAR File Formatp. 1125
Using the jar Utilityp. 1126
JARs and Appletsp. 1130
Appendix B Creating Java Documentationp. 1133
Documenting Your Java Codep. 1133
Output from javadocp. 1135
Documentation Commentsp. 1136
Documenting Classes and Interfacesp. 1138
Documenting Methodsp. 1144
Documenting Fieldsp. 1148
Documenting a Packagep. 1149
Overview Documentationp. 1149
Running javadocp. 1149
Appendix C Keywordsp. 1157
Appendix D ASCII Codesp. 1161
Appendix E Computer Arithmeticp. 1167
Binary Numbersp. 1167
Hexadecimal Numbersp. 1168
Negative Binary Numbersp. 1170
Floating Point Numbersp. 1172
Appendix F P2P. Wrox.Comp. 1175
Index A Methodsp. 1177
Index B Generalp. 1185

Google Preview