Home > Store

Graphic Java 2, Volume 1, AWT, 3rd Edition

Register your product to gain access to bonus material or receive a coupon.

Graphic Java 2, Volume 1, AWT, 3rd Edition

Book

  • Sorry, this book is no longer in print.
Not for Sale

About

Features

  • NEW - Features new chapters on Drag and Drop, Graphics, Colors and Fonts, and Image Manipulation. Pg.___
  • Covers Double Buffering, Sprite Animation, Clipboard and Data Transfer, and other advanced topics. Pg.___
  • The AWT is the cornerstone of the Java Foundation Classes. Volume 1 provides detailed descriptions of every aspect of the 1.2 AWT, including:
    • Event Handling.

    • Layout Managers.

    • Graphics, Colors & Fonts.

    • Image Manipulation.

    • Lightweight Components.

    • Data Transfer & Drag and Drop.

    • Double Buffering.

  • Sprite Animation Java expert David Geary provides clear and in-depth explanations of both fundamental and advanced AWT concepts. Pg.___
  • The layout manager chapter is over 100 pages long and includes what readers have called the best explanation of GridBagLayout on the planet. Pg.___
  • A GridBagLab application on the CD lets you explore GridBagLayout on your own. Pg.___
  • The accompanying CD-ROM includes all of the example code from the book, ready to run on Solaris®, Windows 95, Windows NT, and Macintosh along with the JDK® 1.2 beta for those platforms. Pg.___

Description

  • Copyright 1999
  • Edition: 3rd
  • Book
  • ISBN-10: 0-13-079666-2
  • ISBN-13: 978-0-13-079666-0


7966F-4

Graphic Java 2 is the most comprehensive guide to the Java Foundation Classes (JFC) available. Three volumes cover all aspects of the JFC providing java developers with the skills needed to build professional, cross platform applications that take full advantage of the Java Foundation Classes.

The AWT is the cornerstone of the Java Foundation Classes. Volume 1 provides detailed descriptions of every aspect of the AWT, including:

  • Event Handling
  • Layout Managers
  • Graphics, Colors & Fonts
  • Image Manipulation
  • Lightweight Components
  • Data Transfer & Drag and Drop
  • Double Buffering
  • Sprite Animation

Java expert David Geary provides clear and in-depth explanations of both fundamental and advanced AWT concepts. The layout manager chapter, for example, is over 100 pages long and includes what readers have called the best explanation of GridBagLayout on the planet. A GridBagLab application on the CD lets you explore GridBagLayout on your own.

The accompanying CD-ROM includes all of the example code from the book, ready to run on Solaris(tm), Windows 95, Windows NT, and Macintosh along with the JDK(tm) for those platforms.

Sample Content

Table of Contents

(NOTE: Each Chapter concludes with a summary.)

PART 1. INTRODUCTION: THE JAVA FOUNDATION CLASSES, THE AWT, APPLETS, AND APPLICATIONS.

1. Introduction.

The Java Foundation Classes. The Abstract Window Toolkit. Peers and Platform Independence. Components—The Foundation of the AWT. Components, Containers, and Layout Managers.

2. Applets and Applications.

Java Applets. Java Applications. Combining Applet and Application Code.

PART 2. GRAPHICS AND IMAGES.

3. Graphics.

java.awt.Graphics. Graphics Parameters. The Graphics Coordinate System. Graphics References. More on Drawing and Filling Shapes. Translating a Coordinate System's Origin. Clipping. Graphics Modes. Creating a Graphics.

4. Colors and Fonts.

Color Models. The java.awt.Color Class. System Colors. Fonts and FontMetrics.

5. Loading and Displaying Images.

The Image Class and the Image Package. Image Producers and Image Observers. Loading and Displaying Images. Differences Between Applets and Applications. Waiting for an Image to Load. Painting Images a Scanline at a Time. MediaTracker. Animated GIFS. AWT Components as Image Observers. Creating Images. Loading Images as Resources.

6. Image Filtering.

The ImageProducer Interface. The ImageConsumer Interface. How Image Producers and Image Consumers Interact. AWT Image Filters. ImageConsumer Properties. Implementing Custom Image Filters. Extending RGBImageFilter. Extending ImageFilter. Implementing the ImageConsumer Interface. An Introduction to Double Buffering.

7. Image Manipulation Without Filtering.

Scaling and Flipping Images. Grabbing Pixels. Memory Image Source.

PART 3. EVENTS AND LAYOUT MANAGEMENT.

8. Inheritance-Based Event Handling (AWT 1.02 and Before).

The Original AWT Event Model. Event Modifier Constants. Mouse Button Events. Of Mice and Buttons. Monitoring Mouse Events. Sensing Double Clicking. Action Events. Identifying Components by Label— Just Say No. Shortcomings of the Inheritance-Based Event Model.

9. The Delegation Event Model (AWT 1.1 and Beyond).

The Delegation Event Model. The Big Picture. AWT Adapters. Component Events. Semantic Events. Event Adapters. Inner Classes. Firing AWT Events from Custom Components. Firing Custom Events from Custom Components. Dispatching Events and the AWT Event Queue. Active Events. Inheritance-Based Mechanism. Event Handling Design.

10. Components, Containers, and Layout Managers.

The Big Three of the AWT. Layout Managers. Painting a Container's Components. Forcing a Container to Lay Out Its Components. Standard AWT Layout Managers. The GridBagLayout Layout Manager. Null Layout Managers. Custom Layout Managers.

PART 4. AWT COMPONENTS.

11. The AWT Component Class.

Components. java.awt.Component. Component Properties. Deprecated Methods. Component Location, Bounds, and Coordinates. Component Preferred, Minimum, and Maximum Sizes. Component Visibility and Responsiveness. Components and Peers. Rendering Components. Components and Zorder. Components and Cursors. Components and Serialization. Components and Internationalization. Components and JavaBeans. Components and Tree Locking.

12. Basic Components: Labels, Buttons, Canvases, and Panels.

Labels and Buttons. Canvases and Panels.

13. Item Selectables: Checkboxes, Choices, and Lists.

Choices and Lists.

14. Text Components.

java.awt.TextComponent. java.awt.TextField. java.awt.TextArea.

15. Scrolling: Scrollbars and Scrollpanes.

java.awt.Scrollbar. java.awt.ScrollPane.

16. Windows, Frames, and Dialogs.

java.awt.Window. java.awt.Frame. java.awt.Dialog.

17. Menus.

The Menu Classes. A File Menu. Handling Menu Events. Tear-off Menus. A MenuBar Printer. A FrameWithMenuBar Class. Help Menus. Checkbox Menu Items. Cascading Menus. Dynamically Modifying Menus. Popup Menus.

18. Mouseless Operation and Printing.

Mouseless Operation. Keyboard Traversal. Menu Shortcuts. Printing.

19. Lightweight Components.

Introducing Lightweight Components. A Simple Lightweight Component. Lightweight Containers. Lightweight Components and Zorder. Lightweights and Their Graphics. Lightweights and Preferred Sizes.

PART 5. ADVANCED TOPICS.

20. Clipboard and Data Transfer.

The java.awt.datatransfer Package. The Clipboard Class. The System Clipboard. Local Clipboards. Data Transfer Mechanism. Copying Images to a Clipboard. Transferring Custom AWT Components.

21. Drag and Drop.

The java.awt.dnd Package. Drag Sources and Drop Targets.

22. Custom Dialogs.

The Dialog Classes. WorkDialog. ButtonPanel. Postcard. MessageDialog. YesNoDialog. QuestionDialog.

23. Rubberbanding.

The Rubberband Classes. The Rubberband Base Class. Rubberband Panel. Exercising the Rubberband Classes. Refactoring the Unit Test.

24. Double Buffering.

Double Buffering and Animation. How Double Buffering Works. Draggable Lightweights and a Double Buffered Container.

25. Sprite Animation.

The Participants. Sequences and Sprites. Playfield and DoubleBufferedContainer. Collision Detection. Exercising the Animation Package.

Appendix A: AWT Class Diagrams.
Appendix B: The Graphic Java CD-ROM.
Index.

Preface

Preface

The 1.2 JDK (Java Development Kit) offers vastly improved support over its predecessors for developing graphical user interfaces and graphical applets/applications in the form of the Java Foundation Classes. The Java Foundation Classes are represented by four APIs: AWT, Swing, Accessibility and the 2D API.
The Abstract Window Toolkit (AWT) is Java's original user interface toolkit that provides a basic set of components such as labels, buttons, scrollbars etc. The AWT also includes a great deal of infrastructure for graphical components such as a delegation event model, layout management, and support for data transfer and lightweight components.
Swing is a second user interface toolkit that is built on the AWT's infrastructure. Swing offers a much more extensive set of components than the AWT; Swing's 40 components outnumber the AWT by a 4:1 ratio. Some Swing components (labels, buttons, etc.) are designed to replace their AWT counterparts, whereas other Swing components provide extra capabilities not found in the AWT (trees and tables).
The Accessibility API allows developers to implement Java applets and applications that are accessible to users with disabilities. The Accessibility API can also be used to develop alternative interfaces for nomadic users, such as a hypothetical Java navigational system that tells drivers (instead of showing them with a map display) went to turn in an audible fashion.
The 2D API encompasses a number of major enhancements to the AWT's graphics model in terms of manipulating colors, shapes and images and text.

Why The AWT and Why This Book?
The 1.2 JDK comes with the Swing set of components which includes a complete set of lightweight replacements for the AWT's heavyweight components. As a result, a common misconception is that Swing is a replacement for the AWT, but that is not the case. Swing is built on top of the AWT, and in fact, every Swing component is a bonafide AWT component. Because Swing components are in fact AWT components, it is imperative to have a good grasp of how AWT components behave and a what makes the AWT tick.
Graphic Java is meant, first and foremost, to help you master the AWT. Both fundamental and advanced concepts of the AWT are fully explored in the pages that lie ahead. Each AWT component is examined in detail, and AWT Tips are provided to illuminate some of the AWT's dark corners. No stone is left unturned.

What You'll Find Inside
After reading Graphic Java, you will have a thorough grasp of how the AWT is designed, and how to best take advantage of that design. The following is a sample of the coverage provided in the pages that lie ahead.

Peers
You will understand the peer architecture of the AWT, along with the pros and cons of the peer approach. For instance, you'll know which Component methods behave differently if invoked before a component's peer has been created, and what to do about it.

Clipboard and Data Transfer
You'll understand the data transfer model employed by the AWT, and how to utilize both local clipboards and the system clipboard. While the AWT only provides the ability to transfer strings to and from a clipboard, Graphic Java shows you how to put other data types on the clipboard, with examples of transferring both images and custom components.

Lightweight Components
In addition to being able to implement lightweight custom components, you'll also know how to drag them across a double buffered container, and even how to animate them on a playfield. You will understand how double buffering works, and why lightweight components should be displayed in a double buffered container. You will know the pitfalls of placing lightweight components in a container, and why lightweight containers must be manually fitted with a layout manager.

Layout Managers
You will have a complete grasp of layout managers, including the behemoth, GridBagLayout, and you will be able to implement custom layout managers with ease. You will understand how to force a container to layout its components, and why it is sometimes necessary to do so.

Internationalization and Serialization
You'll be able to internationalize a graphical user interface, and serialize both AWT components and their event listeners.

Scrolling
You will be able to scroll any number of components in a container by using a scrollpane. You'll also understand the limitations of the scrollpane class and why it is sometimes necessary to have a peerless scrolling framework. Of course, we'll discuss the implementation of such a scrolling framework from the Graphic Java Toolkit, which you are free to use for your own purposes.

Graphic Java Content
The delegation event model, lightweight components, clipboard and data transfer, desktop colors, mouseless operation, and printing are all thoroughly covered. You'll also find extensive coverage of scrolling, menus (including pop-up menus), image manipulation, graphics, fonts and fontmetrics, dialogs, text components, etc.

Audience
This book is written for object-oriented developers working in Java. There are numerous books explaining details of the Java language and how it works vis-a-vis Visual Basic, C, C++, etc. The details of the language are left to those books.

Internet Sources of Information
There are several online sources of information on Java. You can find online guides and tutorials on Sun's home page:
http://java.sun.com/

There is an active net newsgroup dedicated to Java:
comp.lang.java

There is also a mailing list where Java aficionados exchange ideas, questions, and solutions. For information about the mailing list, look on the World Wide Web at:
http://java.sun.com/mail.html

From these newsgroups and web sites, you'll be able to locate countless other resources, tutorials, Frequently-Asked-Questions (FAQs), and online magazines dedicated to Java. For updates about this book and information about other books in the SunSoft Press Java Series, look on the web at:
http://www.sun.com/books/books/Geary/Geary.html

For some cool graphics, take a look at:
http://www.pixelsight.com:80/PS/pixelsite/pixelsite.html

Conventions Used in This Book

  • Table P-1 shows the coding conventions used in this book.
  • Table P-1 Coding Conventions
  • Convention
  • Example
  • Class names have initial capital letters.
  • public class LineOfText.
  • Method names have initial lowercase and the rest of the words have an initial capital letter. public int getLength()
  • Variable names have initial lowercase and the rest of the words have an initial capital letter.
    private int length
    private int bufferLength
  • static variables begin with an underscore.
    protected static int _defaultSize = 2;
    Note that, for the most part, methods are referred to without their arguments; however, we include the arguments when the discussion warrants including them.
  • Table P-2 shows the typographic conventions used in this book.
  • Table P-2 Typographic Conventions.
  • Typeface or Symbol
  • Description


  • Indicates that the accompanying code, command, or file is available on the CD that accompanies this book.
  • courier
  • Indicates a command, file name, class name, method, argument, Java keyword, HTML tag, file content, or code excerpt.
  • bold courier
  • Indicates a sample command-line entry.
  • italics
  • Indicates definitions, emphasis, a book title, or a variable that you should replace with a valid value.

Updates

New To This Edition

  • NEW—Features new chapters on Drag and Drop, Graphics, Colors and Fonts, and Image Manipulation.

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020