Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

AhmadLang / Java, How To Program, 2004

.pdf
Скачиваний:
588
Добавлен:
31.05.2015
Размер:
51.82 Mб
Скачать

[Page xlv (continued)]

A Tour of the Optional GUI and Graphics Case Study

In this section, we tour the book's optional 10-section case study on creating graphics and graphical user interfaces (GUIs) in Java. The goal of this case study is to create a polymorphic drawing application in which the user can select a shape to draw, select the characteristics of the shape (such as the color of the shape and whether it is filled with color or hollow) and use the mouse to draw the shape. This integrated case study builds gradually toward that goal, with the reader implementing polymorphic drawing in Chapter 10, adding an event-driven GUI in Chapter 11 and enhancing the drawing capabilities in Chapter 12 with Java 2D. This tour previews the topics covered in each section of the case study. After completing this case study, students will be able to create their own simple graphical applications.

Section 3.9Using Dialog Boxesintroduces graphical user interfaces and demonstrates handling input and output with dialog boxes. We use predefined JOptionPane dialogs to display information and read text in an application.

Section 4.14Creating Simple Drawingsintroduces Java's graphics capabilities. First, we describe Java's coordinate system, then we cover drawing lines and creating a window that displays drawings.

[Page xlvi]

Section 5.10Rectangles and Ovalsexplains how to use the graphics methods that draw rectangles and ovals.

Section 6.13Colors and Filled Shapesdiscusses how computers represent colors, how to use colors in graphics, and how to fill oval or rectangular regions with a solid color.

Section 7.13Drawing Arcsdescribes how Java specifies angles; then we demonstrate drawing arcs (i.e., sections of an oval) by defining an oval and angular positions along the oval.

Section 8.18Using Objects with Graphicsdescribes how to use objects to represent shapes. We create classes to represent each shape type, store these objects in arrays and retrieve the shapes each time we need to draw them.

Section 9.8Displaying Text and Images Using Labelsexplores creating labels and attaching them to the application window. Applications use labels to display information to the user. Labels in Java can display text, an image or both.

Section 10.8Drawing with Polymorphismfocuses on the common characteristics of the classes created in Section 8.18. In this section, we examine these similarities and redesign the individual shape classes so that they inherit their common functionality from a "base" class and can be processed polymorphically.

Exercise 11.18Expanding the Interfaceasks the reader to apply the event-driven GUI programming techniques they learn in Chapter 11. Readers create a GUI that allows users to select the shape to draw and its color, then draw the shape with a mouse. The application stores and manipulates shapes using the classes created in Section 10.8.

Exercise 12.31Adding Java2Dasks the reader to use Java 2D's more elaborate two-dimensional drawing capabilities to create a robust drawing application in which users select a shape's line thickness and fill options (solid colors or gradients that transition between colors). To do this, the reader enhances the shape classes in Exercise 11.18 to store information about each shape's Java 2D features.

[Page xlvi (continued)]

Software Included with Java How to Program, 6/e

A number of for-sale Java development tools are available, but you do not need any to get started with Java. We wrote Java How to Program, 6/e using only the new Java 2 Standard Edition Development Kit (JDK), version 5.0 . The current JDK version can be downloaded from Sun's Java Web site java.sun.com/j2se/downloads/index.html. This site also contains the JDK documentation downloads.

The CD that accompanies Java How to Program, 6/e, contains several Java editors, including BlueJ Version 1.3.5, JCreator Lite Version 3.10 (Windows only), jEdit Version 4.1 and jGRASP Version 1.7.0. The CD also contains the NetBeans™ Version 3.6 Integrated Development Environment (IDE). Windows

and Linux versions of MySQL® 4.0.20 and MySQL® Connector/J Version 3.0.14 are provided for the database processing performed in Chapters 2527. Finally, Apache Tomcat Version 5.0.25 is provided for use with servlets and JavaServer Pages in Chapters 2627. If you have questions about using this software, please read the documentation on the CD, or read our Dive Into™ Series publications, which are available with the resources for Java How to Program, 6/e at www.deitel.com/books/downloads.html. The free Dive-Into™ Series publications help students and instructors familiarize themselves with various Java development tools. These publications include: Dive Into™ NetBeans, Dive Into™ Eclipse, Dive Into™ JBuilder, Dive Into™ jEdit, Dive Into™ jCreator, Dive Into™ jGRASP and Dive Into™ BlueJ.

[Page xlvii]

The CD also contains the book's examples and an HTML Web page with links to the Deitel & Associates, Inc. Web site and the Prentice Hall Web site. This Web page can be loaded to a Web browser to afford quick access to all the resources.

[Page xlvii (continued)]

Teaching Resources for Java How to Program, 6/e

Java How to Program, 6/e, has extensive resources for instructors. The Instructor's Resource CD (IRCD) contains the Solutions Manual with solutions to the vast majority of the end-of-chapter exercises, a Test Item File of multiple-choice questions (approximately two per book section) and PowerPoint slides containing all the code and figures in the text, plus bulleted items that summarize the key points in the text. Instructors can customize the slides.

Prentice Hall's Companion Web Site (www.prenhall.com/deitel) for Java How to Program, 6/e offers resources for students and instructors. For instructors, the Companion Web Site offers a Syllabus Manager, which helps instructors plan courses interactively and create online syllabi.

Chapter-specific resources available for students on the Companion Web Site include:

Chapter objectives

Highlights (e.g., chapter summary)

Outline

Tips (e.g., Common Programming Errors, Error-Prevention Tips, Good Programming Practices, Portability Tips, Performance Tips and Software Engineering Observations)

Online Study Guidecontains additional short-answer self-review exercises (e.g., true/false) with answers and provides immediate feedback to the student

Students can track their results and course performance on quizzes using the Student Profile feature, which records and manages all feedback and results from tests taken on the Companion Web Site. To access the Companion Web Site, visit www.prenhall.com/deitel.

[Page xlvii (continued)]

Java in the Lab

Java in the Lab, Lab Manual to Accompany Java How to Program, 6/e (ISBN 0-13-149497-X) complements Java How to Program, 6/e and Small Java How to Program 6/e with hands-on lab assignments designed to reinforce students' understanding of lecture material. This lab manual is designed for closed laboratoriesregularly scheduled classes supervised by an instructor. Closed laboratories provide an excellent learning environment, because students can use concepts presented in class to solve carefully designed lab problems. Instructors are better able to gauge the students' understanding of the material by monitoring the students' progress in lab. This lab manual also can be used for open laboratories, homework and for self-study. Java How to Program, 6/e, and the lab manual are available individually or together in a value pack (ISBN 0-13-167380-7).

Every chapter in the lab manual is divided into Prelab Activities, Lab Exercises and Postlab Activities. Each chapter contains objectives that introduce the lab's key topics and an assignment checklist that allows students to mark which exercises the instructor has assigned. The lab manual pages are perforated, so students can submit their answers (if required).

Solutions to the lab manual's Prelab Activities, Lab Exercises and Postlab Activities are available in electronic form. Instructors can obtain these materials from their regular Prentice Hall representatives; the solutions are not available to students.

[Page xlviii]

Prelab Activities

Prelab Activities are intended to be completed by students after studying each chapter of Java How to Program, 6/e. Prelab Activities test students' understanding of the textbook material and prepare students for the programming exercises in the lab session. The exercises focus on important terminology and programming concepts and are effective for self-review. Prelab Activities include Matching Exercises,

Fill-in-the-Blank Exercises, Short-Answer Questions, Programming-Output Exercises (determine what short code segments do without actually running the program) and Correct-the-Code Exercises (identify and correct all errors in short code segments).

Lab Exercises

The most important section in each chapter is the Lab Exercises. These teach students how to apply the material learned in Java How to Program, 6/e, and prepare them for writing Java programs. Each lab contains one or more lab exercises and a debugging problem. The Lab Exercises contain the following:

Lab Objectives highlight specific concepts on which the lab exercise focuses.

Problem Descriptions provide the details of the exercise and hints to help students implement the program.

Sample Outputs illustrate the desired program behavior, which further clarifies the problem descriptions and aids the students with writing programs.

Program Templates take complete Java programs and replace key lines of code with comments describing the missing code.

Problem-Solving Tips highlight key issues that students need to consider when solving the lab exercises.

Follow-Up Questions and Activities ask students to modify solutions to lab exercises, write new programs that are similar to their lab-exercise solutions or explain the implementation choices

that were made when solving lab exercises.

Debugging Problems consist of blocks of code that contain syntax errors and/or logic errors. These alert students to the types of errors they are likely to encounter while programming.

Postlab Activities

Professors typically assign Postlab Activities to reinforce key concepts or to provide students with more programming experience outside the lab. Postlab Activities test the students' understanding of the Prelab and Lab Exercise material, and ask students to apply their knowledge to creating programs from scratch. The section provides two types of programming activities: coding exercises and programming challenges. Coding exercises are short and serve as review after the Prelab Activities and Lab Exercises have been completed. The coding exercises ask students to write programs or program segments using key concepts from the textbook. Programming Challenges allow students to apply their knowledge to substantial programming exercises. Hints, sample outputs and pseudocode are provided to aid students with these problems. Students who successfully complete the Programming Challenges for a chapter have mastered the chapter material. Answers to the programming challenges are available at www.deitel.com/books/downloads.html.

[Page xlix]

OneKey, CourseCompassSM, WebCT™ and by Blackboard™

OneKey is Prentice Hall's exclusive new resource that gives instructors and students access to the best online teaching and learning tools through one convenient Web site. OneKey enables instructors to prepare their courses effectively, present their courses more dramatically and assess students easily. An abundance of searchable presentation material together with practice activities and test questionsall organized by chapter or topichelps to simplify course preparation.

Selected content from the Deitels' introductory programming language How to Program series, including Java How to Program, 6/e, is available to integrate into various popular course management systems, including CourseCompass, Blackboard and WebCT. Course management systems help faculty create, manage and use sophisticated Web-based educational tools and programs. Instructors can save hours of inputting data by using Deitel course-management-systems content. [Note: The e-Book included with OneKey contains the entire text of Java How to Program, 6/e.]

Blackboard, CourseCompass and WebCT offer:

Features to create and customize an online course, such as areas to post course information

(e.g., policies, syllabi, announcements, assignments, grades, performance evaluations and progress tracking), class and student management tools, a gradebook, reporting tools, page tracking, a calendar and assignments.

Communication tools to help create and maintain interpersonal relationships between students

and instructors, including chat rooms, whiteboards, document sharing, bulletin boards and private e-mail.

Flexible testing tools that allow an instructor to create online quizzes and tests from questions

directly linked to the text, and that grade and track results effectively. All tests can be inputted into the gradebook for efficient course management. WebCT also allows instructors to administer timed online quizzes.

Support materials for instructors are available in print and online formats.

In addition to the types of tools found in Blackboard and WebCT, CourseCompass from Prentice Hall includes:

CourseCompass course home page, which makes the course as easy to navigate as a book.

An expandable table of contents allows instructors to view course content at a glance and to link to any section.

Hosting on Prentice Hall's centralized servers, which allows course administrators to avoid

separate licensing fees or server-space issues. Access to Prentice Hall technical support is available.

"How Do I" online-support sections are available for users who need help personalizing course sites, including step-by-step instructions for adding PowerPoint slides, video and more.

Instructor Quick Start Guide helps instructors create online courses using a simple, step-by- step process.

To view free online demonstrations and learn more about these Course Management Systems, which support Deitel content, visit the following Web sites:

Blackboard: www.blackboard.com and www.prenhall.com/blackboard

[Page l]

WebCT: www.webct.com and www.prenhall.com/webct

CourseCompass: www.coursecompass.com and www.prenhall.com/coursecompass

[Page l (continued)]

Java 2 Multimedia Cyber Classroom, 6/e Through OneKey

Java How to Program, 6/e and Small Java How to Program, 6/e will now include a free, Web-based interactive multimedia accompaniment to the bookThe Java 2 Multimedia Cyber Classroom, 6/eavailable in spring 2005 through OneKey. Our Web-based Cyber Classroom will include audio walkthroughs of code examples in the text, solutions to about half of the exercises in the book and more. For more information about the new Web-based Cyber Classroom and its availability through OneKey, please visit

our Web site at www.deitel.com or sign up for the free Deitel® Buzz Online e-mail newsletter at www.deitel.com/newsletter/subscribe.html.

Students who use our Cyber Classrooms tell us that they like the interactivity and that the Cyber Classroom is a powerful reference tool. Professors tell us that their students enjoy using the Cyber Classroom and consequently spend more time on the courses, mastering more of the material than in textbook-only courses. For a complete list of our current CD-ROM-based Cyber Classrooms, see the

Deitel® Series page at the beginning of this book, the product listing and ordering information at the end of this book, or visit www.deitel.com, www.prenhall.com/deitel or www.InformIT.com/deitel.

[Page l (continued)]

PearsonChoices

Today's students have increasing demands on their time and money, and they need to be resourceful about how, when and where they study. Pearson/Prentice Hall, a division of Pearson Education, has responded to that need by creating PearsonChoices to allow faculty and students to choose from a variety of textbook formats and prices.

Small Java How to Program 6/e

Small Java How to Program, 6/e is our new 10-chapter alternative print edition to Java How to Program, 6/e. Small Java How to Program, 6/e is focused on first-semester Computer Science (CS1) programming courses and is priced lower than our 29-chapter Java How to Program, 6/e and other competing texts in the CS1 market. The following is a chapter-level table of contents for the book. [Note: This book includes Chapters 110 of Java How to Program, 6/e and their corresponding optional GUI and graphics case study sections, but does not include the OOD/UML optional automated teller machine (ATM) case study.]

Chapters in Both Small Java How to Program, 6/e and Java How to Program, 6/e

Chapter 1Introduction to Computers, the Internet and the Web

Chapter 2Introduction to Java Applications

Chapter 3Introduction to Classes and Objects

Chapter 4Control Statements: Part 1

Chapter 5Control Statements Part 2

Chapter 6Methods: A Deeper Look

Chapter 7Arrays

Chapter 8Classes and Objects: A Deeper Look

Chapter 9Object-Oriented Programming: Inheritance

Chapter 10Object-Oriented Programming: Polymorphism

[Page li]

SafariX WebBooks

SafariX Textbooks Online is a new service for college students looking to save money on required or recommended textbooks for academic courses. This secure WebBooks platform creates a new option in the higher education market; an additional choice for students alongside conventional textbooks and online learning services. Pearson provides students with a WebBook at 50% of the cost of its conventional print equivalent.

SafariX WebBooks are viewed through a Web browser connected to the Internet. No special plug-ins are required and no applications need to be downloaded. Students simply log in, purchase access and begin studying. With SafariX Textbooks Online students can search the text, make notes online, print out reading assignments that incorporate their professors' lecture notes and bookmark important passages they want to review later. They can navigate easily to a page number, reading assignment, or chapter. The Table of Contents of each WebBook appears in the left hand column alongside the text.

We are pleased to offer students the Java How to Program, 6/e SafariX WebBook available for January 2005 classes. Visit www.pearsonchoices.com for more information. Other Deitel titles available as SafariX WebBooks include Small Java How to Program, 6/e and Simply C++: An Application-Driven Tutorial Approach. Visit www.safarix.com/tour.html for more information.