Java After Hours: 10 Projects You'll Never Do at Work

Overview

Take your Java programming skills beyond the ordinary. Java After Hours: 10 Projects You'll Never Do at Work will make Java your playground with ten detailed projects that will have you exploring the various fields that Java offers to build exciting new programs. You'll learn to:

  • Create graphics ...
See more details below
Paperback
$28.18
BN.com price
(Save 29%)$39.99 List Price
Other sellers (Paperback)
  • All (11) from $1.99   
  • New (6) from $23.58   
  • Used (5) from $1.99   
Sending request ...

Overview

Take your Java programming skills beyond the ordinary. Java After Hours: 10 Projects You'll Never Do at Work will make Java your playground with ten detailed projects that will have you exploring the various fields that Java offers to build exciting new programs. You'll learn to:

  • Create graphics interactively on Web servers
  • Send images to Web browsers
  • Tinker with Java's Swing package to make it do seemingly impossible things
  • Search websites and send e-mail from Java programs
  • Use multithreading, Ant and more!

Increase your Java arsenal by taking control of Java and explore its possibilities with Java After Hours.

Read More Show Less

Product Details

  • ISBN-13: 9780672327476
  • Publisher: Sams
  • Publication date: 6/20/2005
  • Pages: 336
  • Product dimensions: 7.00 (w) x 9.06 (h) x 0.74 (d)

Meet the Author

Java After Hours: 10 Projects You'll Never Do at Work About the Author

Steve Holzner has been writing about Java for as long as Java has been around—nearly two dozen books over many years. He has written a total of 92 books, which have sold more than two million copies in 18 languages. He has also been a contributing editor at PC Magazine and has been on the faculty of MIT and Cornell University. He runs his own training company, Onsite Global, for corporate programmers at http://www.onsiteglobal.com, teaching nearly all current programming topics.

Read More Show Less

Read an Excerpt

IntroductionIntroduction

Welcome to Java After Hours: 10 Projects You'll Never Do at Work, the book that lets you kick back and take control of Java. This book is not to be taken too seriously—it's meant to be fun. So relax; you're in the driver's seat here. This is where you get to make Java do some outrageous things for you.Why Is This Book Unique?

If you're a programmer, too many of the programming books you've read have probably not been much fun at all. In fact, many of them are grim slogs.

Not this one. This is designed to be the computer book for the rest of us who just want to kick back and get a little enjoyment out of what we do everyday.

That's not to say that the programs you're going to find here aren't powerful and that you can't learn some interesting techniques from them—you can. There's all kinds of cool stuff in here, from creating a multithreaded hockey game to an online chat room, from an Internet-based intercom to a temperature forecaster that draws JPEG images online and sends them to browsers.

There's a lot packed in here, and as the book's author, my hope is that at least some of it will make you take a second look and say, "Cool!"Who Is This Book For?

This book is for you if you're a Java programmer and you're tired of the usual run-of-the-mill stuff.

This book is also for you if you want to learn some of the techniques involved: sending JPEGs back from a web server, grabbing web pages from Java code, creating drop shadows in Java2D, using online filters, controlling any other programrobotically, and more.About the Book's Code

This book contains 10 projects, along with some minor projects used for illustration purposes (one of these subprojects builds an entire web server you can run from your desktop, given an Internet connection and a fixed IP address, which you probably have if you have a broadband connection).

Here's an overview of the code in this book:

  • Chapter 1: Aquarium—A multithreaded fish-swimming project with fish that swim realistically against a bubbly background.

  • Chapter 2: Slapshot!—A multithreaded hockey game that moves. You play against the computer and set the speed. And when you set the speed in the upper 90s, you've got a good chance of losing.

  • Chapter 3: The Graphicizer—An image-editing and conversion tool. This one lets you read in JPG, PNG, or GIF files and save images in JPG or PNG format. You can work with images pixel by pixel, embossing them, sharpening them, brightening them, blurring them, reducing them, and so on. And you can even undo the most recent change.

  • Chapter 4: Painter—Lets you draw your own images from scratch—ellipses, rectangles, lines, and so on. You can even draw freehand with the mouse. You can also draw each shape open or filled, using a texture fill, a solid color fill, or a gradient fill. You can draw text. You can give shapes a drop shadow, or make them transparent. You can draw using thin lines or thick lines. You can set the drawing color. And not only can you save your work when done, you can also read in images and work on them, annotating them with text or adding your own graphics.

  • Chapter 5: The Chat project—In this project you create your own private Internet chat room that will keep you in touch with anyone over the Internet. All you need is Internet access and a Java-enabled web server. You can have as many people in your chat room as you like. What they type, you can see, and what you type, they can see. Type all you like—all you're paying for is the local Internet connection.

  • Chapter 6: WebLogger—Log access to your website. This project lets you log users who access your website by access time, authentication type, username (if they've logged in), user IP address, the URL they accessed on your site, their browser type, the milliseconds they were there for, and so on. All without their knowledge.

  • Chapter 7: The Robot project—Another cool one. This project lets you control any other program by remote control; just tell it what to do. You can send text to the other program you're controlling. You can use the Alt and Ctrl keys. You can send tab characters, the Enter key, or the Esc key. You can also use the mouse—just enter the screen location (in pixels) where you want the mouse to move to. Then click the mouse, right-click it, or double-click it. You can also take screen captures. Want to automate working with any program? The Robot will do it.

  • Chapter 8: The Browser project—This project lets you create a fully featured browser (subclassing Microsoft Internet Explorer) in your Java applications.

  • Chapter 9: The Intercom project—This project lets two people type across the Internet. You just start up the project, connect with the click of a button, and you've got your own connection: Everything you type into the Intercom, the other use can see, and everything the other user types, you can see. This one is a client/server application and connects directly across the Internet using its own protocol—unlike the Chat project, no Java-enabled web server is needed here at all.

  • Chapter 10: The Forecaster project—Displays a four-day temperature forecast for your area, starting with today's high and low temperatures. All you've got to do is to tell the Forecaster your ZIP Code, and it'll give you the forecast by reading its data from the National Weather Service and sending a JPEG image from the server back to the browser.

You can download all the code used throughout this book from the Sams website at http://www.samspublishing.com. Enter this book's ISBN (without the hyphens) in the Search box and click Search. When the book's title is displayed, click the title to go to a page where you can download the code.Conventions Used in This Book

This book uses various typefaces:

  • A special monospace font is used to help you distinguish code-related terms from regular English, for. Here's an example: The actionPerformed method handles menu selections, setting the appropriate drawing flags as needed.

  • As I develop the code in this book, the new code being added will appear this way:

    import java.awt.*;import java.awt.event.*;public class Intercom1 extends Frame implements Runnable, ActionListener{ public static void main(String args) { new Intercom1(); } . . .}

  • Each chapter has a real-world scenario, which looks like this:

    Real-world Scenario - You're going to find real-world experience and insights in real-world scenarios like this one. These track what's going on in the computer industry, in the technology under discussion, or just generally in programmer's lives these days.

  • Notes, tips, and cautions look like this:

    Note - Notes provide additional information related to the surrounding topics.

    Tip - Tips provide shortcuts to make a task or better ways to accomplish certain features.

    Caution - Cautions alert you to potential problems, or to common pitfalls you should avoid.

And that's all you need. Get ready and turn to Chapter 1, "Making Fish Swim in the Multithreaded Aquarium," to crank things up and make those fish swim.

© Copyright Pearson Education. All rights reserved.

Read More Show Less

Table of Contents

Introduction

1. Making Fish Swim in the Multithreaded Aquarium

Building the Aquarium

Loading the Fish

Moving Those Fish

Double-Buffering the Drawing

Creating the Fish

Making the Fish Swim

Drawing the Fish

Conclusion

2. Slapshot! The Interactive Hockey Game

Creating the Rink

Starting a Game

Moving Those Pucks

Getting the Pucks to Bounce Off Each Other

How the Computer Blocks Pucks

How the User Blocks Pucks

Setting the Speed

Creating the Pucks

Conclusion

3. The Graphicizer Image-Editing and Conversion Tool

Creating the Graphicizer Window

Opening an Image File

Painting the Image

Saving an Image File

Embossing an Image

Sharpening an Image

Brightening an Image

Blurring an Image

Reducing an Image

Undoing a Change

Conclusion

4. Creating Stunning Graphics with Painter

Creating the Painter Window

Handling Menu Selections

Handling the Mouse

Drawing Some Graphics

Drawing Lines

Drawing Ellipses

Drawing Rectangles

Drawing Rounded Rectangles

Drawing Freehand

Drawing Text

Drawing the Final Image

Setting Colors

Conclusion

5. Chatting on the Internet with the Chat Room

Creating the Chat HTML Page

Creating JSP Pages

Getting the Tomcat Web Server

Using Some Java in JSP

Reading Data from HTML Controls in JSP

Using Request Objects

Using the Session and Application Objects

Creating a Hit Counter Using Sessions

Creating a Hit Counter Using Applications

Displaying the Current User Comments

Storing New Comments

Conclusion

6. Who's There? Logging Access to Your Website with WebLogger

All About Filters

Creating a Simple Filter

Writing the Code

Configuring the Web Server

Restricting Access Based on Time of Day

Restricting Access Based on Password

Creating WebLogger

Collecting User Data

Logging That Data

Conclusion

7. Running Any Program Via Remote Control with the Robot

Running the Robot

Creating the Robot's Window

Reading the Robot's Commands

Executing Commands

Sending Keystrokes

Sending Mouse Events

Making the Robot Wait

Making the Robot Beep

Taking a Screenshot

Making the Robot Reappear

Conclusion

8. Creating a Custom Web Browser in Java: The Browser Project

Introducing the SWT

Getting the SWT

Creating an SWT Application

Working with SWT Events

Using SWT Toolbars

Creating the Browser Project

Conclusion

9. Typing Across the Internet: The Intercom Project

Using the Intercom

Creating Intercom 1

Connecting to Intercom 2

Sending Text to Intercom 2

Reading Text from Intercom 2

Creating Intercom 2

Connecting to Intercom 1

Sending Text to Intercom 1

Reading Text from Intercom 1

Conclusion

10. Getting a Graphical Weather Forecast: The Forecaster Project

Creating the Forecaster JSP

Getting the ZIP Code

Gathering the Weather Data

Graphing the Data

Creating the Desktop Version

Conclusion

Index

Read More Show Less

Preface

Introduction

Welcome to Java After Hours: 10 Projects You'll Never Do at Work, the book that lets you kick back and take control of Java. This book is not to be taken too seriously—it's meant to be fun. So relax; you're in the driver's seat here. This is where you get to make Java do some outrageous things for you.

Why Is This Book Unique?

If you're a programmer, too many of the programming books you've read have probably not been much fun at all. In fact, many of them are grim slogs.

Not this one. This is designed to be the computer book for the rest of us who just want to kick back and get a little enjoyment out of what we do everyday.

That's not to say that the programs you're going to find here aren't powerful and that you can't learn some interesting techniques from them—you can. There's all kinds of cool stuff in here, from creating a multithreaded hockey game to an online chat room, from an Internet-based intercom to a temperature forecaster that draws JPEG images online and sends them to browsers.

There's a lot packed in here, and as the book's author, my hope is that at least some of it will make you take a second look and say, "Cool!"

Who Is This Book For?

This book is for you if you're a Java programmer and you're tired of the usual run-of-the-mill stuff.

This book is also for you if you want to learn some of the techniques involved: sending JPEGs back from a web server, grabbing web pages from Java code, creating drop shadows in Java2D, using online filters, controlling any other program robotically, and more.

About the Book's Code

This book contains 10 projects, along with some minor projects used for illustration purposes (one of these subprojects builds an entire web server you can run from your desktop, given an Internet connection and a fixed IP address, which you probably have if you have a broadband connection).

Here's an overview of the code in this book:

  • Chapter 1: Aquarium—A multithreaded fish-swimming project with fish that swim realistically against a bubbly background.
  • Chapter 2: Slapshot!—A multithreaded hockey game that moves. You play against the computer and set the speed. And when you set the speed in the upper 90s, you've got a good chance of losing.
  • Chapter 3: The Graphicizer—An image-editing and conversion tool. This one lets you read in JPG, PNG, or GIF files and save images in JPG or PNG format. You can work with images pixel by pixel, embossing them, sharpening them, brightening them, blurring them, reducing them, and so on. And you can even undo the most recent change.
  • Chapter 4: Painter—Lets you draw your own images from scratch—ellipses, rectangles, lines, and so on. You can even draw freehand with the mouse. You can also draw each shape open or filled, using a texture fill, a solid color fill, or a gradient fill. You can draw text. You can give shapes a drop shadow, or make them transparent. You can draw using thin lines or thick lines. You can set the drawing color. And not only can you save your work when done, you can also read in images and work on them, annotating them with text or adding your own graphics.
  • Chapter 5: The Chat project—In this project you create your own private Internet chat room that will keep you in touch with anyone over the Internet. All you need is Internet access and a Java-enabled web server. You can have as many people in your chat room as you like. What they type, you can see, and what you type, they can see. Type all you like—all you're paying for is the local Internet connection.
  • Chapter 6: WebLogger—Log access to your website. This project lets you log users who access your website by access time, authentication type, username (if they've logged in), user IP address, the URL they accessed on your site, their browser type, the milliseconds they were there for, and so on. All without their knowledge.
  • Chapter 7: The Robot project—Another cool one. This project lets you control any other program by remote control; just tell it what to do. You can send text to the other program you're controlling. You can use the Alt and Ctrl keys. You can send tab characters, the Enter key, or the Esc key. You can also use the mouse—just enter the screen location (in pixels) where you want the mouse to move to. Then click the mouse, right-click it, or double-click it. You can also take screen captures. Want to automate working with any program? The Robot will do it.
  • Chapter 8: The Browser project—This project lets you create a fully featured browser (subclassing Microsoft Internet Explorer) in your Java applications.
  • Chapter 9: The Intercom project—This project lets two people type across the Internet. You just start up the project, connect with the click of a button, and you've got your own connection: Everything you type into the Intercom, the other use can see, and everything the other user types, you can see. This one is a client/server application and connects directly across the Internet using its own protocol—unlike the Chat project, no Java-enabled web server is needed here at all.
  • Chapter 10: The Forecaster project—Displays a four-day temperature forecast for your area, starting with today's high and low temperatures. All you've got to do is to tell the Forecaster your ZIP Code, and it'll give you the forecast by reading its data from the National Weather Service and sending a JPEG image from the server back to the browser.

You can download all the code used throughout this book from the Sams website at http://www.samspublishing.com. Enter this book's ISBN (without the hyphens) in the Search box and click Search. When the book's title is displayed, click the title to go to a page where you can download the code.

Conventions Used in This Book

This book uses various typefaces:

  • A special monospace font is used to help you distinguish code-related terms from regular English, for. Here's an example: The actionPerformed method handles menu selections, setting the appropriate drawing flags as needed.
  • As I develop the code in this book, the new code being added will appear this way:
  • import java.awt.*;import java.awt.event.*;public class Intercom1 extends Frame implements Runnable, ActionListener{ public static void main(String args) { new Intercom1(); } . . .}
  • Each chapter has a real-world scenario, which looks like this:

  • Real-world Scenario - You're going to find real-world experience and insights in real-world scenarios like this one. These track what's going on in the computer industry, in the technology under discussion, or just generally in programmer's lives these days.

  • Notes, tips, and cautions look like this:

  • Note - Notes provide additional information related to the surrounding topics.


    Tip - Tips provide shortcuts to make a task or better ways to accomplish certain features.


    Caution - Cautions alert you to potential problems, or to common pitfalls you should avoid.

And that's all you need. Get ready and turn to Chapter 1, "Making Fish Swim in the Multithreaded Aquarium," to crank things up and make those fish swim.

© Copyright Pearson Education. All rights reserved.

Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star

(0)

4 Star

(0)

3 Star

(0)

2 Star

(0)

1 Star

(0)

Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation

Reminder:

  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

 
Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously
Sort by: Showing 1 Customer Reviews
  • Anonymous

    Posted July 24, 2005

    try learning SWT and Eclipse

    Veteran author Holzner has come forth with a deliberately quirky book. It has an informal choice of Java programming topics, where these are unlikely to be seen in other, more comprehensive and conventional Java texts. Plus, Holzner uses the latest major release, Java 1.5. To be sure, you really must have some nodding acquaintance with Java. Not necessarily 1.5, mind you. But part of the book's focus is that it does not waste your time going over basic issues like syntax and the core classes. The book exposes you to more than just the standard Java 1.5 distribution from Sun. You should already know that the latter has two sets of widgets - the original AWT and the newer Swing, where Swing is often considered to be better than AWT. But there is another widget toolkit, called SWT. Freely offered by IBM. It has been well received by many Java programmers as being superior to AWT and Swing. In Chapter 8, on making a custom web browser, for example, Holzner shows the virtues of SWT. Purely in terms of broadening your Java experience, it is worth checking SWT out. Holzner also puts in a strong plug for Eclipse. An Integrated Development Environment that is free and open source. (It also originated from IBM.) It offers the promise of a very nice, high productivity context in which to code your Java. Its proponents suggest that Eclipse and Java can match any Microsoft IDE for coding VB.NET or C#. You see, if you treat the book correctly, it's not the topics themselves that are the most important items. Don't get me wrong. They are certainly interesting in their own right. Rather, it's the broadening of your knowledge en route that is the book's main attraction.

    Was this review helpful? Yes  No   Report this review
Sort by: Showing 1 Customer Reviews

If you find inappropriate content, please report it to Barnes & Noble
Why is this product inappropriate?
Comments (optional)