Sams Teach Yourself Java™ in 24 Hours (Covering Java 7 and Android)

(singke) #1

ptg


ptg


Contents v

PART III: Working with Information in
New Ways


HOUR 9: Storing Information with Arrays
Creating Arrays.......................................... 108
Using Arrays.............................................. 109
Multidimensional Arrays.............................. 111
Sorting an Array........................................ 111
Counting Characters in Strings.................... 113


HOUR 10:Creating Your First Object
How Object-Oriented Programming Works...... 121
Objects in Action...................................... 122
What Objects Are...................................... 124
Understanding Inheritance.......................... 125
Building an Inheritance Hierarchy................ 125
Converting Objects and Simple Variables...... 127
Creating an Object.................................... 132


HOUR 11:Describing What Your Object Is
Like
Creating Variables...................................... 137
Creating Class Variables............................ 139
Creating Behavior with Methods.................. 140
Putting One Class Inside Another................ 146
Using the thisKeyword.............................. 147
Using Class Methods and Variables.............. 148


HOUR 12:Making the Most of Existing Objects
The Power of Inheritance............................ 155
Establishing Inheritance.............................. 157
Working with Existing Objects...................... 159
Storing Objects of the Same Class in Vectors 160
Creating a Subclass.................................. 164


PART IV: Programming a Graphical User
Interface


HOUR 13:Building a Simple User Interface
Swing and the Abstract Windowing Toolkit.... 169
Using Components.................................... 170
Creating Your Own Component.................... 180


HOUR 14:Laying Out a User Interface
Using Layout Managers.............................. 187
Laying Out an Application............................ 192

HOUR 15:Responding to User Input
Getting Your Programs to Listen.................. 201
Setting Up Components to Be Heard............ 202
Handling User Events................................ 202
Completing a Graphical Application.............. 207

HOUR 16:Building a Complex User Interface
Scroll Panes.............................................. 219
Sliders.................................................... 222
Change Listeners...................................... 223
Using Image Icons and Toolbars.................. 227

PART V: Moving into Advanced Topics

HOUR 17:Creating Interactive Web Programs
Standard Applet Methods............................ 235
Putting an Applet on a Web Page................ 238
Creating an Applet.................................... 239
Sending Parameters from a Web Page.......... 242
Handling Parameters in an Applet................ 243
Using the Object Tag.................................. 245

HOUR 18:Handling Errors in a Program
Exceptions................................................ 249
Throwing Exceptions.................................. 256
Throwing and Catching Exceptions................ 258

HOUR 19:Creating a Threaded Program
Threads.................................................... 265
Working with Threads................................ 270
Starting with init().................................. 272
Catching Errors as You Set Up URLs............ 272
Handling Screen Updates in the paint()
Method.................................................... 273
Starting the Thread.................................... 274
Handling Mouse Clicks.............................. 276
Displaying Revolving Links.......................... 276
Free download pdf