E-Books: Java™ After Hours: 10 Projects You'll Never Do at Work
By Steven Holzner
By Steven Holzner
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 seriouslyit'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 themyou 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 scratchellipses, 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 likeall 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 mousejust 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 protocolunlike 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.
For Download: