intTypePromotion=1
zunia.vn Tuyển sinh 2024 dành cho Gen-Z zunia.vn zunia.vn
ADSENSE

giáo trình Java By Example phần 1

Chia sẻ: Thái Duy Ái Ngọc | Ngày: | Loại File: PDF | Số trang:66

205
lượt xem
65
download
 
  Download Vui lòng tải xuống để xem tài liệu đầy đủ

Giáo trình CD Giáo trình Learn JaVa By Example dành cho học viên Aptech. Bao gồm lý thuyết, hướng dẫn minh họa cụ thể trên NetBeans . Ngoài ra còn có các bài kiểm tra về lý thuyết của học viên,có soft NetBeans kèm theo, Nói chung là rất dễ học đối với các bạn mới làm quen với JaVa.

Chủ đề:
Lưu

Nội dung Text: giáo trình Java By Example phần 1

  1. Java By Example Clayton Walnum CONTENTS Introduction Who This Book Is For q Hardware and Software Requirements q Compiling the Programs in This Book q A Word to the Wise q On to the Wonderful World of Java q Chapter 1 Java Overview The Java Story q Introducing Java q Java Programs q The Java Developer's Kit q Where Is Java? q Example: Installing HotJava q Example: Installing the JDK q Summary q Review Questions q Review Exercises q http://www.ngohaianh.info
  2. Chapter 2 Running Java Applets The Sample Java Applets q The Appletviewer Tool r Example: Running TicTacToe r The Animator Applet r The BarChart Applet r Other Demo Applets r Adding Applets to an HTML Document q Optional Attributes for Applets r Applet Parameters r Non-Java Browsers r Example: A Java-Powered Home Page r Summary q Review Questions q Review Exercises q Chapter 3 Applets and the Internet Local and Remote Applets q Local Applets r Remote Applets r Clients and Servers q Security q Example: Your Pages on the Web q Summary q Review Questions q Review Exercises q Chapter 4 Object-Oriented Programming Concepts From Switches to Objects q An Obvious, Yet Brilliant, Solution q Object-Oriented Programming q http://www.ngohaianh.info
  3. Encapsulation r Classes as Data Types r Inheritance r Polymorphism r Example: Encapsulation, Inheritance, and Polymorphism r Summary q Review Questions q Review Exercises q Chapter 5 Constants and Variables Constants q Variables q Naming Constants and Variables q Example: Creating Your Own Identifiers q Data Types q Integer Values r Floating-Point Values r Character Values r Boolean Values r Variable Scope q Example: Determining a Variable's Scope r Summary q Review Questions q Review Exercises q Chapter 6 Simple Input and Output Windows and Graphics q Displaying Text in an Applet q Example: Creating and Running Applet1 r How Applet1 Works r Getting Input from the User q How Applet2 Works r http://www.ngohaianh.info
  4. Example: Retrieving text from a TextField control r How Applet3 Works r Displaying Numerical Values q Summary q Review Questions q Review Exercises q Chapter 7 Math Operators The Addition Operator q Example: Using the Addition Operator r Example: Multiple Additions r The Subtraction Operator q Example: Using the Subtraction Operator r Example: Multiple Subtractions Using Mixed Data Types r Example: Casting a Result to a Different Data Type r The Multiplication Operator q Example: Multiplication and Data Types r The Division Operator q Example: Integer Versus Floating-Point Division r The Modulo Operator q The Increment Operator q The Decrement Operator q Example: Using Mathematical Calculations in an Applet q How Applet5 Works r The Order of Operations q Example: Order of Operations r Example: More Order of Operations r Example: Still More Order of Operations r Example: One Last Order of Operations r Summary q Review Questions q Review Exercises q http://www.ngohaianh.info
  5. Chapter 8 Expressions Types of Expressions q Expressions Within Expressions q Comparison Operators q Example: Using Comparison Operators r Logical Operators q Example: Using Logical Operators r Example: Using Multiple Logical Operators r Example: Combining Different Comparison and Logical Operators r Writing Logical Expressions q Order of Operations q Summary q Review Questions q Review Exercises q Chapter 9 The if and switch Statements Controlling Program Flow q Program Flow and Branching q The if statement q Example: The Form of an if Statement r Multiple if Statements r Multiple-Line if Statements r The else Clause r Example: Using the if Statement in a Program r The switch Statement q Example: Using the break Statement Correctly r Example: Using the switch Statement in a Program r Summary q Review Questions q Review Exercises q http://www.ngohaianh.info
  6. Chapter 10 The while and do-while Loops The while Loop q Example: Using a while Loop r Example: Using a while Loop in a Program r The do-while Loop q Example: Using a do-while Loop r Example: Using a do-while Loop in a Program r Summary q Review Questions q Review Exercises q Chapter 11 The for Loop Introducing the for Loop q Example: Using a for Loop q Example: Using a for Loop in a Program q Changing the Increment Value q Example: Looping with Different Increments q Using Variables in Loops q Example: Controlling for Loops with Variables q Summary q Review Questions q Review Exercises q Chapter 12 Functions The Top-Down Approach to Programming q Example: Using Functions as Subroutines q Defining and Calling Functions q Example: Using Functions to Return Values q Example: Putting Functions to Work q Summary q Review Questions q http://www.ngohaianh.info
  7. Review Exercises q Chapter 13 Arrays An Introduction to Arrays q Example: Creating an Array r Example: Using a Variable as a Subscript r Multidimensional Arrays q Example: Creating a Two-Dimensional Array r Example: Using Two-Dimensional Arrays in an Applet q Summary q Review Questions q Review Exercises q Chapter 14 Classes Classes and Objects q Defining a Simple Class r Declaring Fields for a Class r Defining a Constructor r Example: Creating an Object by Calling a Constructor r Defining Methods r Example: Using Classes in Applets q Understanding the Applet q Using Inheritance q Creating a Subclass r Adding Fields and Methods to the Subclass r Example: Adding Fields and Methods r Example: Using a Subclass in a Program q Overriding Methods of the Superclass q The this Keyword q Summary q Review Questions q Review Exercises q http://www.ngohaianh.info
  8. Chapter 15 Writing a Simple Applet The Simplest Java Applet q The Five Stages of an Applet's Life Cycle q Example: Overriding the Life Cycle Methods q Summary q Review Questions q Review Exercises q Chapter 16 Drawing Graphics The Applet's Canvas q Example: Using the Coordinate System q Drawing Shapes q Example: Drawing a Rectangle q Example: Drawing Other Shapes q Understanding the ShapeApplet Applet q Drawing Ovals r Drawing Arcs r Example: Drawing Arcs in an Applet r Drawing Polygons r Summary q Review Questions q Review Exercises q Chapter 17 Graphical Text Dealing with Graphical Text q Getting Font Attributes r Example: Displaying Font Information r Getting Font Metrics r Example: Displaying Font Metrics r Creating Fonts q Example: Creating a Font with Multiple Styles r http://www.ngohaianh.info
  9. Using the Font r Example: Displaying Different Sized Fonts r Summary q Review Questions q Review Exercises q Chapter 18 Label and Button Controls Labels q Example: Creating a Label r Methods of the Label Class r Buttons q Example: Adding a Button to an Applet r Handling Multiple-Button Events r Example: Handling Multiple Buttons in an Applet r Summary q Review Questions q Review Exercises q Chapter 19 Checkbox and TextField Controls Checkboxes q Example: Creating Nonexclusive Checkboxes r Checkbox Groups r Checkbox Methods r Example: Handling Checkboxes in an Applet r Responding to a Checkbox Event r Example: Handling Checkbox Events in an Applet r TextFields q TextField Methods r Example: Using Echo Characters r Summary q Review Questions q Review Exercises q http://www.ngohaianh.info
  10. Chapter 20 Choice Menu, Text Area, and Scrolling List Controls Choice Menus q Example: Creating a Choice Menu r Choice Menu Methods r Example: Responding to Menu Events in an Applet r Scrolling Lists q Example: Creating a Single-Selection List r Example: Creating a Multiple-Selection List r Example: Creating a Scrolling List r Methods of the List Class r Example: Using a Scrolling List in an Applet r The TextArea Control q Example: Creating a TextArea Control r Methods of the TextArea Class r Summary q Review Questions q Review Exercises q Chapter 21 Scrollbar and Canvas Controls Scrollbars q Example: Creating a Scrollbar r Responding to a Scrollbar r Example: Using a Scrollbar in an Applet r Canvases r Example: Using a Canvas in an Applet r Summary q Review Questions q Review Exercises q http://www.ngohaianh.info
  11. Chapter 22 Panels and Layout Managers Panels q Example: Creating and Using Panels r Layout Managers q The FlowLayout Manager q Example: Creating a FlowLayout Manager r The GridLayout Manager q Creating a GridLayout Manager r The BorderLayout Manager q Creating a BorderLayout Manager r The CardLayout Manager q The CardLayout Manager Methods r Example: Creating a CardLayout Manager r The GridBagLayout Manager q Creating and Setting the GridBagLayout Manager r Creating and Setting a GridBagConstraints Object r Example: Using a GridBagLayout Manager in an Applet r Understanding the GridBagApplet Applet r Summary q Review Questions q Review Exercises q Chapter 23 Windows and Menu Bars Displaying a Window q Example: Displaying a Window in an Applet r Example: Creating a Window Class r Example: Adding Components to a Window r Using Menu Bars q Creating and Setting a MenuBar Object r Adding Menus to a Menu Bar r Adding Menu Items to Menus r Example: Using a Menu Bar in a Frame Window r http://www.ngohaianh.info
  12. Summary q Review Questions q Review Exercises q Chapter 24 Dialog Boxes Using a Dialog Box q Creating the Dialog Box r Creating the Dialog Box's Layout r Displaying the Dialog Box r Removing the Dialog Box r Methods of the Dialog Class r Example: A Dialog Box for Text Input r Summary q Review Questions q Review Exercises q Chapter 25 Mouse and Keyboard Events The Event Object q The Mouse q Handling Mouse Clicks r Example: Using Mouse Clicks in an Applet r Handling Mouse Movement r Example: Responding to Mouse Movement in an Applet r The Keyboard q Responding to Key Presses r Predefined Key Constants r Key Modifiers r Example: Using Key Presses in an Applet r Handling Events Directly q Example: Overriding handleEvent() in an Applet r Summary q Review Questions q http://www.ngohaianh.info
  13. Review Exercises q Chapter 26 Configurable Applets Types of Users q Parameters and Applets q Example: Setting and Retrieving a Parameter's Value r Example: Using a Parameter in an Applet r Multiple Parameters q Example: Using Multiple Parameters in an Applet r Default Parameter Values q Example: Using Default Parameters in an Applet r Summary q Review Questions q Review Exercises q Chapter 27 Images and Sounds Image Types q Loading and Displaying an Image q Example: Using the getDocumentBase() Method r Example: Using the getCodeBase() Method r Loading an Image r Displaying an Image r Example: Displaying an Image in an Applet r Playing a Sound q Example: Using the play() Method r Example: Playing a Sound in an Applet r Controlling Sounds r Example: Using an AudioClip in an Applet r Summary q Review Questions q Review Exercises q http://www.ngohaianh.info
  14. Chapter 28 Communications URL Objects q Example: Creating an URL Object r URL Exceptions r The Applet Context q Example: Using an AppletContext to Link to an URL r Example: Using an AppletContext in an Applet r Creating a "Favorite URLs" Applet q Summary q Review Questions q Review Exercises q Chapter 29 Packages and Interfaces Packages q Creating Your Own Packages r Example: Creating a Simple Package r Example: Using the New Package r Example: Extending the Package r Interfaces q The Basic Interface r Example: Creating an Interface r Implementing an Interface r Summary q Review Questions q Review Exercises q Chapter 30 Exceptions Java's Exceptions q Throwing an Exception q Types of Exceptions q Determining the Exceptions to Handle q http://www.ngohaianh.info
  15. Example: Catching a Runtime Exception r Example: Handling Multiple Exceptions r Summary q Review Questions q Review Exercises q Chapter 31 Threads Two Kinds of Threads q Converting a Class to a Thread q Declaring the Class as Implementing the Runnable Interface r Implementing the run() Method r Declaring a Thread Object r Creating and Starting the Thread Object r Stopping the Thread r Example: Using a Thread in an Applet r Deriving a Class from Thread q Example: Creating a Thread Class r Example: Using a Separate Thread in an Applet r Synchronizing Multiple Threads q Example: Using a Synchronized Method r Understanding ThreadApplet3 r Summary q Review Questions q Review Exercises q Chapter 32 Writing Java Applications About Java Applications q The Simplest Java Application q Example: Building an Application r Example: Getting an Application's Arguments r Windowed Applications q Example: Changing an Applet to an Application r http://www.ngohaianh.info
  16. Understanding the FaceApp Application r Summary q Review Questions q Review Exercises q Chapter 33 Development Tools Overview The Tools q Using Appletviewer q Example: Loading More Than One Applet at a Time r Running the Debugger from Appletviewer r Using HotJava q Using Java's Documentation Creator q Javadoc Tags r Example: Using Doc Tags r Example: Documenting an Applet r Javadoc Options r Using the Disassembler q Using the C Header Generator q Using the Debugger q Summary q Review Questions q Review Exercises q Chapter 34 Using the Compiler What the Compiler Does q Running the Compiler q Setting the Class Path r Specifying the Target Directory r Example: Setting the Target Directory r Creating Debugging Tables r Example: Adding Debugging Tables to an Applet r Suppressing Warnings r http://www.ngohaianh.info
  17. Optimizing a Program r Switching On Verbose Output r Summary q Review Questions q Review Exercises q Chapter 35 Using the Interpreter What the Interpreter Does q Running the Interpreter q Keeping Files Up to Date r Setting the Class Path r Switching On Verbose Output r Example: Running an Application with Verbose Output r Getting Help r Summary q Review Questions q Review Exercises q Chapter 36 The Java Class Libraries The Packages q The java.lang Package q Data-Type Wrappers r Example: Using the Data-Type Wrappers r The System Class r Example: Getting System Properties r The Math Class r The String Class r Example: Using the String Class r The io Package q Example: Reading a File r The awt Package q Summary q http://www.ngohaianh.info
  18. Review Questions q Review Exercises q Appendix A Answers to Review Questions Chapter 1 q Chapter 2 q Chapter 3 q Chapter 4 q Chapter 5 q Chapter 6 q Chapter 7 q Chapter 8 q Chapter 9 q Chapter 10 q Chapter 11 q Chapter 12 q Chapter 13 q Chapter 14 q Chapter 15 q Chapter 16 q Chapter 17 q Chapter 18 q Chapter 19 q Chapter 20 q Chapter 21 q Chapter 22 q Chapter 23 q Chapter 24 q Chapter 25 q Chapter 26 q Chapter 27 q Chapter 28 q Chapter 29 q http://www.ngohaianh.info
  19. Chapter 30 q Chapter 31 q Chapter 32 q Chapter 33 q Chapter 34 q Chapter 35 q Chapter 36 q Appendix B Glossary Appendix C IDEs and Tools IDEs q Diva r Java+ r JavaMaker r Tools q AppletGen r VbToJava r PortaFilter r Summary q Credits Java By Example Copyright© 1996 by Que® Corporation All rights reserved. Printed in the United States of America. No part of this book may be used or reproduced in any form or by any means, or stored in a database or retrieval system, without prior written permission of the publisher except in the case of brief quotations embodied in critical articles and reviews. Making copies of any part of this book for any purpose other than your own personal use is a violation of United States copyright laws. For information, address Que Corporation, 201 W. 103rd Street, Indianapolis, IN 46290. You may reach Que's direct sales line by calling 1-800-428-5331. ISBN: 0-7897-0814-0 http://www.ngohaianh.info
  20. This book is sold as is, without warranty of any kind, either express or implied, respecting the contents of this book, including but not limited to implied warranties for the book's quality, performance, merchantability, or fitness for any particular purpose. Neither Que Corporation nor its dealers or distributors shall be liable to the purchaser or any other person or entity with respect to any liability, loss, or damage caused or alleged to have been caused directly or indirectly by this book. All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. Que cannot attest to the accuracy of this information. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark. HTML conversion by : M/s. LeafWriters (India) Pvt. Ltd. Website : http://leaf.stpn.soft.net e-mail : leafwriters@leaf.stpn.soft.net President and Publisher : Roland Elgey Associate Publisher : Joseph B. Wikert Director of Marketing : Lynn E. Zingraf Editorial Services Elizabeth Keaffaber Managing Editor Sandy Doell Director Title Manager Bryan Gambrel Acquisitions Fred Stone Editor Product Director Ben Milstead Production Editor Mitzi Foster Gianakos Editors Anne Owen, Assistant Product Kim Margolius Joe Williams Marketing Manager Technical Editors David Medinets Acquisitions Jane Brownlow Coordinator Operations Patty Brooks Editorial Assistant Andrea Duvall Coordinator Book Designer Kim Scott Cover Designer Ruth Harvey Production Team Steve Adams, Marcia Brizendine, Jason Carr, Jenny Earhart, Joan Evan, Jessica Ford, Trey Frank, Amy Gornik, Jason Hand, Daniel Harris, Damon Jordan, Daryl Kessler, Clint Lahnen, Bob LaRoche, Kaylene Riemen, Laura Robbins, Bobbi Satterfield, Kelly Warner, Jeff Yesh, Jody York Indexer John Hulse http://www.ngohaianh.info
ADSENSE

CÓ THỂ BẠN MUỐN DOWNLOAD

 

Đồng bộ tài khoản
2=>2