How to Create Interactive Web Programs with Java
Excerpted from Sams Teach Yourself Programming with Java in 24 Hours by Rogers Cadenhead. ISBN 0672328445, Copyright © 2006. Used with the permission of Sams Publishing.
Now that Java has made the transition from a child prodigy to an established language, it is being used for all kinds of large-scale business software and other applications. However, for some people, the core appeal of the language remains a type of program that Java made possible: the applet.
Applets are programs designed to run as part of a World Wide Web page. When a Java applet is encountered on a page, it is downloaded to the user’s computer and begins running.
During this hour you’ll be introduced to applet programming and Java Web Start, a way to install and run Java software from within a web browser.
Programming applets with Java is much different from creating applications with Java. Because applets must be downloaded from a page each time they are run, they’re smaller than most applications to reduce download time. Also, because applets run on the computer of the person using the applet, they have numerous security restrictions in place to prevent malicious or damaging code from being run.
The following topics will be covered:
• Displaying information in an applet
• Stopping and starting an applet
• Putting an applet on a web page
• Customizing an applet with parameters on a web page
• Receiving parameters in an applet
• Running applets with the Java Plug-in
Standard Applet Methods
The first step in the creation of an applet is to make it a subclass of JApplet, a class that’s part of the Swing package, javax.swing. An applet is treated as a visual window inside a web page, so JApplet is part of Swing alongside clickable buttons, scrollbars, and other components of a program’s user interface.
JApplet is a subclass of Applet, a class in the java.applet package. Being part of this hierarchy enables the applets you write to use all the behavior and attributes they need to be run as part of a web page. Before you begin writing any other statements in your applets, they will be able to interact with a web browser, load and unload themselves, redraw their window in response to changes in the browser window, and handle other necessary tasks.
In applications, programs begin running with the first statement inside the main()block statement and end with the last closing bracket (}) that closes out the block. There is no main() method in a Java applet, so there is no set starting place for the program. Instead, an applet has a group of standard methods that are handled in response to specific events as the applet runs.
The following are the events that could prompt one of the applet methods to be handled:
• The program is loaded for the first time, which causes the applet’s init() and start() methods to be called.
• Something happens that requires the applet window to be redisplayed, which causes the applet’s paint() method to be called.
• The program is stopped by the browser, which calls the applet’s stop() method.
• The program restarts after a stop, which calls the start() method.
• The program is unloaded as it finishes running, which calls the destroy()method.
The following is an example of a bare-bones applet:
public class Skeleton extends javax.swing.JApplet {
// program will go here
}
Unlike applications, applet class files must be public because the JApplet class is also public. (If your applet uses other class files of your own creation, they do not have to be declared public.)
Your applet’s class inherits all the methods that are handled automatically when needed: init(), paint(), start(), stop(), and destroy(). However, none of these methods do anything. If you want something to happen in an applet, you have to override these methods with new versions in your applet program.
Painting an Applet Window
The paint() method is used to display text, shapes, and graphics within the applet window. Whenever something needs to be displayed or redisplayed on the applet window, the paint() method handles the task. You also can force paint() to be handled with the following statement in any method of an applet:
repaint();
Aside from the use of repaint(), the main time the paint() method is handled is when something changes in the browser or the operating system running the browser. For example, if a user minimizes a web page containing an applet, the paint() method will be called to redisplay everything that was onscreen in the applet when the applet is later restored to full size.
Unlike the other methods you will be learning about during this hour, paint()takes an argument. The following is an example of a simple paint() method:
public void paint(Graphics screen) {
Graphics2D screen2D = (Graphics2D)screen;
// display statements go here
}
The argument sent to the paint() method is a Graphics object. The Graphics class of objects represents an environment in which something can be displayed, such as an applet window. As you did with Swing programs, you may cast this to a Graphics2D object to employ more sophisticated graphical features.
Later this hour, you’ll learn about drawString(), a method for the display of text that’s available in both the Graphics and Graphics2D classes.
If you are using a Graphics or Graphics2D object in your applet, you have to add the following import statements before the class statement at the beginning of the source file:
import java.awt.Graphics;
import java.awt.Graphics2D;

Initializing an Applet
The init() method is handled once—and only once—when the applet is run. As a result, it’s an ideal place to set up values for any objects and variables that are needed for the applet to run successfully. This method is also a good place to set up fonts, colors, and the screen’s background color. Here’s an example:
public void init() {
FlowLayout flo = new FlowLayout();
setLayout(flo);
JButton run = new JButton(“Run”);
add(run);
}
If you are going to use a variable in other methods, it should not be created inside an init() method because it will only exist within the scope of that method.
For example, if you create an integer variable called displayRate inside the init()method and try to use it in the paint() method, you’ll get an error when you attempt to compile the program. Create any variables you need to use throughout a class as object variables right after the class statement and before any methods.
Starting and Stopping an Applet
At any point when the applet program starts running, the start() method will be handled. When a program first begins, the init() method is followed by the start() method. After that, in many instances there will never be a cause for the start() method to be handled again. In order for start() to be handled a second time or more, the applet has to stop execution at some point.
The stop() method is called when an applet stops execution. This event can occur when a user leaves the web page containing the applet and continues to another page. It also can occur when the stop() method is called directly in a program.
Destroying an Applet
The destroy() method is an opposite of sorts to the init() method. It is handled just before an applet completely closes down and completes running.
This method is used when something has been changed during a program that should be restored to its original state. It’s another method you’ll use more often with animation than with other types of programs.
Putting an Applet on a Web Page
Applets are placed on a web page in the same way that anything unusual is put on a page: HTML markup tags describe the applet, which a web browser loads along with the other parts of the page. If you have used HTML to create a web page, you know that it’s a way to combine formatted text, images, sound, and other elements together. HTML uses special commands called tags that are surrounded by marks, including img for the display of images, p for the insertion of a paragraph mark, and to center the text that follows until a tag is reached.
The performance of some of these HTML tags can be affected by attributes that determine how they function. For example, src is an attribute of the img tag, and it provides the name of the image file that should be displayed. The following is an example of an img tag:

One way to place applets on a web page is by using an applet tag and several attributes. The following is an example of the HTML required to put an applet on a page:

Sorry, no dice … this requires a Java-enabled browser.

The code attribute identifies the name of the applet’s class file. If more than one class file is being used with an applet, code should refer to the main class file that is a subclass of the JApplet class.
If there is no code attribute, all files associated with the applet should be in the same folder as the web page that loads the program. codebase should contain a reference to the folder or subfolder where the applet and any related files can be found. In the preceding example, codebase indicates that the StripYahtzee applet can be found in the javadir subfolder.
The height and width attributes designate the exact size of the applet window on the web page. It must be big enough to handle the things you are displaying in your applet.
In between the opening tag and the closing tag, you can provide an alternate of some kind for web users whose browser software cannot run Java programs (less than two percent of all web users run browsers that fall into this group).
In the preceding example, the text “Sorry, no dice…this requires a Java-enabled browser” is displayed in place of the applet on a browser such as Lynx, which does not support Java. You can put instructions here on how to download a Java-enabled browser. You also can include hyperlinks and other HTML elements.
Another useful attribute, align, designates how an applet will be displayed in relation to the surrounding material on the page, including text and graphics. The value align=”left” lines up the applet to the left of adjacent page elements and align=”right” lines it up to the right.
A Sample Applet
This hour’s first project is an applet that displays the string “Saluton mondo!”, the traditional Esperanto greeting that is becoming more traditional by the hour. You’ll take a look at how applets are structured by re-creating the Saluton application from Hour 2, “Writing Your First Program,” as a program that can run on a web page.
Load your word processor and create a new file called SalutonApplet.java. Enter the text of Listing 17.1 into the file and save it when you’re done.

This applet does not need to use the start(), stop(), or destroy() methods, so they are not included in the program. Compile the program with the javac compiler tool, if you’re an JDK user, or another tool.
home / programming / java_24 / 1

Drawing in An Applet Window
Text is displayed in an applet window by using the drawString() method of the Graphics2D class, which draws text in a graphical user interface component. The drawString() method is similar in function to the System.out.println()method that displays information to the system’s standard output device.
Before you can use the drawString() method, you must have a Graphics or Graphics2D object that represents the applet window.
The paint() method of all applets includes a Graphics object as its only argument, which can be cast to a Graphics2D object:
Graphics2D screen2D = (Graphics2D)screen;
When you have created a Graphics2D object like this, you can call its drawString() method to display text on the area represented by the object.
The following three arguments are sent to drawString():
• The text to display, which can be several different strings and variables strung together with the + operator
• The x position (in an (x,y) coordinate system) where the string should be displayed
• The y position where the string should be displayed
The (x,y) coordinate system in an applet is used with several methods. It begins with the (0,0) point in the upper-left corner of the applet window. Figure 17.1 shows how the (x,y) coordinate system works in conjunction with the statement on Line 12 of SalutonApplet.java.

Testing the SalutonApplet Program
Although you have compiled the SalutonApplet program into a class file, you cannot run it using a Java interpreter such as java. If you do, you’ll get an error message looking like this:
Exception in thread “main” java.lang.NoSuchMethodError: main
The error occurs because a Java interpreter runs applications by calling its main() method. Applets don’t include this method. Instead, to run an applet, you need to create a web page that loads the applet. To create a web page, open up a new file on your word processor and call it SalutonApplet.html. Enter Listing 17.2 and then save the file.

All applets you write can be tested with the appletviewer tool that comes with the Java Development Kit. You can see the output of the SalutonApplet applet by typing the following:
appletviewer SalutonApplet.html
One thing to note about appletviewer is that it only runs the applets that are included in a web page, and does not handle any of the other elements such as text and images.
Applets can also be loaded by web browsers, if they are equipped with the Java Plug-in. To attempt this at a command line, type the following command:
SalutonApplet.html
You can also choose File, Open from the browser’s menu to find and open the page.
Figure 17.2 shows a screen capture of SalutonApplet loaded in Mozilla Firefox.

If you can’t get this applet to run in Firefox or another web browser, the most likely reason is that the browser needs the Java Plug-in.
The Java Plug-in
Though popular web browsers began including their own Java interpreters with the first release of the language in the mid-’90s, these interpreters failed to keep current.
To make it possible for Java 2 applets to run in current browsers, Sun Microsystems offers the Java Plug-in, a substitute for a browser’s built-in interpreter that supports the most up-to-date version of the language.
A plug-in is a program that works in conjunction with a web browser to expand its functionality. Plug-ins handle a type of data that the browser normally could not handle. Apple offers a plug-in to display QuickTime movies, Macromedia distributes a plug-in to run Flash animation files, and many other kinds of special content are supported in this manner.
If you installed the Java Development Kit, you were given a chance to install the Java Plug-in at the same time.
The Java Plug-in runs Java applets in place of the web browser’s Java interpreter. Once the Java Plug-in is installed, all future Java 2 applets will run automatically if they specify that the Plug-in should be used to run them.
The plug-in is part of the Java Runtime Environment, which can be downloaded at no cost from Sun’s Java site at the address http://java.com.
Sending Parameters from a Web Page
Now that you have had some experience writing computer programs, you might be feeling one of the strongest emotions of the programmer: compiler angst. Even though it takes no more than 15 seconds to compile most programs, that time can seem interminable when you’re debugging a program. Write, save, compile, Aargh—an error! Write, save, compile, Aargh! Write, save, compile, Aargh!… As this vicious cycle repeats itself, it’s easy to become world-weary as a program is compiled and recompiled.
One of the driving forces behind parameter use in Java applets is the fear and loathing of compilation. Parameters enable you to change elements of an applet without editing or recompiling anything. They also make the program more useful.
Parameters are stored as part of the web page that contains an applet. They are created using the HTML tag param and its two attributes: name and value. You can have more than one param tag with an applet, but all of them must be between the opening tag and the closing tag, which also support parameters).
The following is an applet tag that includes several parameters:

This example could be used to send news headlines to an applet that scrolls them across the screen. Because news changes all the time, the only way to create a program of this kind is with parameters.
You use the name attribute to give the parameter a name. This attribute is comparable to giving a variable a name. The value attribute gives the named parameter a value.
Receiving Parameters in the Applet
You have to do something in your Java program to retrieve the parameters on the web page or they will be ignored. The getParameter() method of the JApplet class retrieves a parameter from a param tag on a web page. The parameter name, which is specified with the name attribute on the page, is used as an argument to getParameter(). The following is an example of getParameter() in action:
String display1 = getParameter(“headline1”);
The getParameter() method returns all parameters as strings, so you have to convert them to other types as needed. If you want to use a parameter as an integer, you could use statements such as the following:
int speed;
String speedParam = getParameter(“speed”);
if (speedParam != null) {
speed = Integer.parseInt(speedParam);
}
This example sets the speed variable by using the speedParam string. You have to test for null strings before setting speed because the parseInt() method cannot work with a null string. When you try to retrieve a parameter with getParameter() that was not included on a web page with the param tag, it will be sent as null, which is the value of an empty string.
Workshop: Handling Parameters in an Applet
The next project you’ll undertake has little practical value, except perhaps as a taunting device. The ShowWeight applet takes a person’s weight and displays it under several different units. The applet takes two parameters: a weight in pounds, and the name of the person who weighs that amount. The weight is used to figure out the person’s weight in ounces, kilograms, and metric tons, all of which are displayed.
Create a new file with your word processor and give it the name ShowWeight.java. Enter Listing 17.3 into the file. Then save and compile the file.

The init() method is where the two parameters are loaded into the applet. Because they come from the web page as strings, they must be converted into the form you need: a floating-point number for the lbs variable, and a string for name.
Converting a string to a floating-point number requires two steps: converting the string to a Float object and then converting that object to a variable of the type float.

Lines 20–22 are used to convert the lbs variable into different units of measure. Each of these statements has (float) in front of the conversion equation. This is used to cast the result of the equation into a floating-point number.
The paint() method of the applet uses the drawString() method of the Graphics2D class to display a line of text onscreen. The paint() method has three arguments: the text to display, and the x and y positions where the text should be shown.
Before you can test the ShowWeight applet, you need to create a web page that contains the applet. Open up a new file on your word processor and name it ShowWeight.html. Enter Listing 17.4 and save it when you’re done.

Use a web browser equipped with the Java Plug-in to see the ShowWeight applet. This demonstration uses Konishiki as its example because the American-born sumo wrestling champion weighs in at more than 605 pounds, making him the largest of these immodest, bikini-wearing behemoths. You can substitute anyone whose weight is either exemplary or well-known. Figure 17.3 shows an example of output from the applet. As you can see, Konishiki’s workout regimen doesn’t include a lot of fatfree SnackWell’s Devil’s Food Cakes.
To make the applet display a different name along with a different value for the weight parameter, all you have to change is the ShowWeight.html file. The applet itself will continue to work correctly.

Java Web Start
One of the issues you must deal with as a Java programmer is how to make your software available to the people who will be using your work.
Applications require a Java interpreter, so one must either be included with the application, or users must install an interpreter themselves. The easiest solution is to require that users download and install the Java Runtime Environment from Sun’s web site at http://java.com.
Regardless of how you deal with the requirement for an interpreter, you distribute an application like any other program, making it available on a CD, website, or some other means. A user must run an installation program to set it up, if one is available, or copy the files and folders manually.
Applets are easier to make available, because they can be run by web browsers. There are several drawbacks to offering applets instead of applications, most importantly the default security policy for applets, which makes it impossible for them to read and write data on a user’s computer, among other restrictions.
Java supports another way to make applications available to users: Java Web Start, a method of downloading and running applications by clicking links on web pages. Java Web Start, which requires the Java Plug-in, offers a way to install and run applications as if they were applets. Here’s how it works:
• A programmer packages an application into a Java Archive file along with a file that uses the Java Network Launching Protocol (JNLP), part of Java Web Start.
• The file is published on a web server along with a web page that links to that file.
• A user loads the page with a browser and clicks the link.
• If the user does not have the Java Runtime Environment, a dialog box opens asking whether it should be downloaded and installed.
• The Java Runtime Environment installs and runs the program, opening new frames and other interface components like any other application. The program is saved in a cache, so it can be run again later without requiring installation.
To see it in action, visit Sun’s Java Web Start site at http://java.sun.com/products/ javawebstart/demos.html. The Web Start Demos page contains pictures of several Java applications, each with a Launch button you can use to run the application, as shown in Figure 17.4.

Click the Launch button of one of the applications. If you don’t have the Java Runtime Environment yet, a dialog box opens asking whether you would like to download and install it.
The runtime environment includes the Java Plug-in, a Java interpreter that adds support for the current version of the language to browsers such as Internet Explorer and Mozilla. The environment can also be used to run applications, whether or not they make use of Java Web Start.
When an application is run using Java Web Start, a title screen will be displayed on your computer briefly and the application’s graphical user interface will appear.
Figure 17.5 shows one of the demo applications offered by Sun, a military strategy game in which three black dots gang up upon a red dot and attempt to keep it from moving into their territory.

As you can see in Figure 17.5, the application looks no different than any of the applications you created during the preceding 16 hours. Unlike applets, which are presented in conjunction with a web page, applications launched with Java Web Start run in their own windows, as if they were run from a command line.

One thing that’s different about a Java Web Start application is the security that can be offered to users. When an application attempts to do some things such as reading and writing files, the user can be asked for permission.
For example, another one of the demo programs is a text editor. When you try to save a file with this application for the first time, the Security Advisory dialog box opens (see Figure 17.6).

If the user does not permit something, the application will be unable to function fully. The kinds of things that would trigger a security dialog are the same things that are not allowed by default in applets: reading and writing files, loading network resources, and the like.
Once an application has been run by Java Web Start, it is stored in a cache, enabling you to run it again later without installation. The only exception is when a new version of the application has become available. In this circumstance, the new version will be downloaded and installed in place of the existing one automatically.
Using Java Web Start
Any Java application can be run using Java Web Start, as long as the web server that will offer the application is configured to work with the technology. To prepare an application to use Java Web Start, you must save the application’s files in a Java Archive (JAR) file, create a special Java Web Start file for the application, and upload the files to the web server.
The special file that must be created uses Java Network Launching Protocol (JNLP), an XML file format that specifies the application’s main class file, its JAR archive, and other things about the program.

The next project you will undertake is to use Java Web Start to launch and run the LottoMadness application from Hour 15, “Responding to User Input.” To get ready, put a copy of that project’s files in your main Java programming folder. The files you need are LottoEvent.class and LottoMadness.class, though you might also want LottoEvent.java and LottoMadness.java, in case you decide to make any changes to the application.
The first thing you must do is package all of an application’s class files into a Java Archive (JAR) file along with any other files it needs. If you are using the Software Development Kit, you can create the JAR file with the following command:
jar -cf LottoMadness.jar LottoEvent.class LottoMadness.class
A JAR file called LottoMadness.jar is created that holds both of the class files.
Next you should create an icon graphic for the application, which will be displayed when it is loaded and used as its icon in menus and desktops. The icon can be in either GIF or JPEG format, and should be 64 pixels wide and 64 pixels tall.
For this project, if you don’t want to create a new icon, you can download lottobigicon.gif from the book’s website. Go to http://www.java24hours.com and open the Hour 17 page. Right-click the lottobigicon.gif link and save the file to the same folder as your LottoMadness.jar file.
The final thing you must do is to create the JNLP file that describes the application. Listing 17.5 contains a JNLP file used to distribute the LottoMadness application. Open your word processor and enter the text of this listing, then save the file as LottoMadness.jnlp.

The structure of a JNLP file is similar to the HTML markup required to put a Java applet on a web page. Everything within marks is a tag, and tags are placed around the information the tag describes. There’s an opening tag before the information and a closing tag after it.
For example, Line 7 of Listing 17.5 contains the following text:

In order from left to right, this line contains the opening tag . The text between the tags—LottoMadness Application— is the title of the application, which will be displayed when it is loaded and used in menus and shortcuts.

How to Create Interactive Web Programs with Java
Excerpted from Sams Teach Yourself Programming with Java in 24 Hours by Rogers Cadenhead. ISBN 0672328445, Copyright © 2006. Used with the permission of Sams Publishing.
The difference between opening tags and closing tags is that closing tags begin with a slash (/) character and opening tags do not. In Line 8, is the opening tag, is the closing tag, and these tags surround the name of the vendor who created the application. Place your own name within these tags, taking care not to alter the or tags around it.
Some tags have an opening tag only, such as Line 11:

The tag indicates that the application can be run even if the user is not connected to the Internet. If it was omitted from the JNLP file, the opposite would be true, and the user would be forced to go online before running this application.
In XML, all tags that do not have a closing tag end with /> instead of >.
Tags also can have attributes, which are another way to define information in an XML file. An attribute is a word inside a tag that is followed by an equals sign and some text within quotes.
For example, consider Line 9 of Listing 17.5:

This is the tag, and it has one attribute, href. The text between the quote marks is used to set the value of this attribute to http://www.java24hours.com. This defines the home page of the application—the web page that users should visit if they want to read more information about the program and how it works.
The LottoMadness JNLP file defines a simple Java Web Start application that does not make use of any Java features that require special permission.
In addition to the tags that have already been described, Listing 17.5 defines other information required by Java Web Start.
Line 1 designates that the file uses XML and the UTF-8 character set. This same line can be used on any of the JNLP files you create for applications.
Line 2 is a comment. Like other comments in Java, it’s placed in the file solely for the benefit of humans. Java Web Start will ignore it.
Lines 3–5 indicate where the JNLP file for this application can be found. The codebase attribute in Line 4 is the URL of the folder that contains the JNLP file. The href attribute in Line 5 is the name of the file. These lines indicate that the file is at the web address http://www.cadenhead.org/book/java24hours/java/ LottoMadness.jnlp.
Lines 6 and 12 use the and tags to surround information about the application. Tags can contain other tags in XML: This tag contains , , , , and tags.<br /> Line 10 indicates the location of the program’s icon, which uses the codebase attribute described previously. In this example, the file is at the web address http:// <a href="http://www.cadenhead.org/book/java24hours/java/lottobigicon.gif" rel="nofollow">http://www.cadenhead.org/book/java24hours/java/lottobigicon.gif</a>.<br /> Lines 13 and 16 use the and tags to surround information about resources used by the application.<br /> Line 14 indicates the version of the Java interpreter that should run the application: 1.5, which sets up the application to use Java 2 version 5 (which has the internal version number 1.5)<br /> Line 15 indicates the application’s JAR file. This also uses codebase, so this file is in <a href="http://www.cadenhead.org/book/java24hours/java/LottoMadness.jar" rel="nofollow">http://www.cadenhead.org/book/java24hours/java/LottoMadness.jar</a>.<br /> Line 17 indicates which class file should be run to start the application: LottoMadness. Note that the .class file extension is not specified—only the name of the class itself.<br /> Line 18 ends the definition of this JNLP file. All JNLP files must be contained within an opening tag and a closing tag.<br /> After you have created this file, change Line 4 of Listing 17.5 so that it refers to the folder on a web server where your application’s JAR file, icon file, and JNLP file will be stored.<br /> Upload all three of the files to this folder, then run your browser and load the JNLP file using its full web address. If your web server is configured to support Java Web Start, the application will be loaded and begin running, as in Figure 17.7.<br /> If your server does not support Java Web Start, which is more likely than not because it is a relatively new technology, you may see the text of your JNLP file loaded in a page and the application will not open.</p> <p>A web server must be configured to recognize that JNLP files are a new type of data that should be run as an application, not delivered to the user as text in a browser window. On an Apache web server, the server administrator can support JNLP by adding the following line to the server’s mime-types (or .mime-types) file:<br /> application/x-java-jnlp-file JNLP</p> <p>Summary<br /> Most of the hours in this book focus on applications, primarily because most Java programmers today don’t do a lot of work designing applets for the World Wide Web.<br /> Writing applets is a good way for beginners to develop their skills as Java programmers for the following reasons:<br /> • Applets are usually smaller in scope, making their creation a less daunting task.<br /> • You can find thousands of sample applets on the World Wide Web, including many with the source file available from which to learn.<br /> • You can make applets available to a global audience at low to no cost through the Web, exposing your work to more people who can offer comments and suggestions.<br /> Q&A<br /> Q Is there a reason why the codebase attribute should be used in an applet tag?<br /> A If all Java programs are grouped into their own subfolder, as indicated by codebase, this structure might improve the way a website is organized, but there’s no other reason why using codebase is better than omitting it. The choice is a matter of personal preference.<br /> Q What happens if the height and width specified for an applet don’t leave enough room for the information that is displayed in the paint() method?<br /> A The information will be drawn off-screen, beyond the edges of the applet window, and won’t be visible at any point while the applet runs. Choosing the right dimensions for an applet is largely a matter of trial-and-error until you find the right size for both the height and width attributes of the applet tag. You can’t resize an applet window from within a Java program, so the only way to control its size is by using the height and width attributes. Fortunately, you can change the web page’s HTML without having to recompile the Java program.<br /> Q What is the Peter Principle?<br /> A The principle was an idea popularized in the book The Peter Principle: Why Things Always Go Wrong by Laurence Peter with Raymond Hull.<br /> Peter, a Canadian-born author, psychologist and professor, put forth the following principle: In the workplace, every employee rises to his own level of incompetence.<br /> If an employee does a good job, he is repeatedly promoted until he eventually reaches a level where he cannot do the work—and is no longer promoted.<br /> I was promoted to write computer books in 1996 and have remained in the position for nine years.<br /> Quiz<br /> The following questions test your knowledge of applets.<br /> Questions<br /> 1. What type of argument is used with the paint() method?<br /> • a. A Graphics object<br /> • b. A Graphics2D object<br /> • c. None<br /> 2. Which method is handled right before an applet finishes running?<br /> • a. decline()<br /> • b. destroy()<br /> • c. defenestrate()<br /> 3. Why can’t all variables needed in an applet be created inside the init() method?<br /> • a. The scope of the variables would be limited to the method only.<br /> • b. Federal legislation prohibits it.<br /> • c. They can be created there without any problems.<br /> Answers<br /> 1. a. The Graphics object keeps track of the behavior and attributes needed to display things on-screen in the applet window. You might create a Graphics2 object inside the method, but it isn’t sent as an argument.<br /> 2. b.<br /> 3. a. Variables that are used in more than one method of a class should be created right after the class statement but before any methods begin.<br /> Activities<br /> You can apply your applet programming knowledge with the following activities:<br /> • Write an applet in which the text that is displayed moves each time the applet window is repainted.<br /> • Install the Java Plug-in with your preferred browser, if you’re on a Windows or Solaris system, and try the sample applets provided from Sun’s Java Plug-in page.<br /> To see a Java program that implements the first activity, visit the book’s website at <a href="http://www.java24hours.com" rel="nofollow">http://www.java24hours.com</a>.<br /> Excerpted from Sams Teach Yourself Programming with Java in 24 Hours by Rogers Cadenhead. ISBN 0672328445, Copyright © 2006. Used with the permission of Sams Publishing.</p> <div class="wpa" style="position: relative; width:300px; text-align: center; padding: 0; margin: 10px auto; overflow: hidden; clear: both;"> <a style="position: absolute; text-align: left; display: block; font: 9px/1 sans-serif; text-decoration: underline;" href="http://en.wordpress.com/about-these-ads/" rel="nofollow">About these ads</a> <script type="text/javascript"> var wpcom_adclk_hovering = false; var wpcom_adclk_recorded = false; var wpcom_adclk_theme = "Motion"; var wpcom_adclk_slot = "wpcom_below_post"; var wpcom_adclk_network = ( typeof wpcom_adclk_network === "undefined" ) ? "" : wpcom_adclk_network ; jQuery(document).ready( function() { function wpcom_adclk_hover_yes() { wpcom_adclk_hovering = true; } function wpcom_adclk_hover_no() { wpcom_adclk_hovering = false; } jQuery(".wpa").click(wpcom_adclk_click); jQuery(".wpa iframe").hover( wpcom_adclk_hover_yes, wpcom_adclk_hover_no ); jQuery(".wpa object").hover( wpcom_adclk_hover_yes, wpcom_adclk_hover_no ); jQuery(window).blur( function() { if ( wpcom_adclk_hovering ) { wpcom_adclk_click(); } }); }); function wpcom_adclk_impression() { var stat_gif = document.location.protocol + "//pixel.wp.com/g.gif?v=wpcom-no-pv"; stat_gif += "&x_ads_imp_theme=" + wpcom_adclk_theme; stat_gif += "&x_ads_imp_placement="+wpcom_adclk_slot; stat_gif += "&x_ads_imp_network=" + wpcom_adclk_network; stat_gif += "&x_ads_imp_theme_network="+wpcom_adclk_theme+"_"+wpcom_adclk_network; new Image().src = stat_gif + "&baba=" + Math.random(); return true; } function wpcom_adclk_click() { if (wpcom_adclk_recorded) { return true; } // no double counting var stat_gif = document.location.protocol + "//pixel.wp.com/g.gif?v=wpcom-no-pv"; stat_gif += "&x_ads_click_theme=" + wpcom_adclk_theme; stat_gif += "&x_ads_click_placement="+wpcom_adclk_slot; stat_gif += "&x_ads_click_network=" + wpcom_adclk_network; stat_gif += "&x_ads_click_theme_network="+wpcom_adclk_theme+"_"+wpcom_adclk_network; new Image().src = stat_gif + "&baba=" + Math.random(); wpcom_adclk_recorded = true; var now=new Date(); var end=now.getTime()+250; while(true){now=new Date();if(now.getTime()>end){break;}} return true; } if ( typeof GA_googleAddAttr == 'function' ) { GA_googleAddAttr("AdOpt", "1"); GA_googleAddAttr("Origin", "other"); GA_googleAddAttr("LangId", "1"); GA_googleAddAttr("Domain", "telleme.wordpress.com"); GA_googleAddAttr("BlogId", "16784990"); GA_googleAddAttr("PageURL", "http://telleme.wordpress.com/2010/11/27/how-to-create-interactive-web-programs-with-java/"); GA_googleAddAttr("Autotag", "technology"); GA_googleAddAttr("theme_bg", "002728"); GA_googleAddAttr("theme_border", "034450"); GA_googleAddAttr("theme_text", "ffffff"); GA_googleAddAttr("theme_link", "a8ef9d"); GA_googleAddAttr("theme_url", "afdaff"); GA_googleAddAdSensePageAttr("google_page_url", "http://telleme.wordpress.com/2010/11/27/how-to-create-interactive-web-programs-with-java/"); GA_googleFillSlot("wpcom_below_post"); } </script> </div> <style type="text/css"> div.wpa>div { margin-top: 1em; } #google_ads_div_wpcom_below_post_adsafe_ad_container { display: block !important; } </style> <script type="text/javascript"> jQuery( window ).load( function() { if ( jQuery(".wpa script[src*='virool.com']").length > 0 || jQuery(".wpa script[src*='shareth.ru']").length > 0 || jQuery(".wpa iframe[src*='boomvideo.tv']").length > 0 || jQuery(".wpa iframe[src*='viewablemedia.net']").length > 0 || jQuery(".wpa .sharethrough-placement").length > 0 ) { jQuery( '.wpa' ).css( 'width', '400px' ); } setTimeout(function(){if(typeof GS_googleAddAdSenseService !== 'function'){new Image().src=document.location.protocol+"//pixel.wp.com/g.gif?v=wpcom-no-pv&x_noads=adblock&baba="+Math.random()}},100); } ); </script> <div id="jp-post-flair" class="sharedaddy sharedaddy-dark sd-like-enabled sd-sharing-enabled"><div class="sharedaddy sd-sharing-enabled"><div class="robots-nocontent sd-block sd-social sd-social-icon-text sd-sharing"><h3 class="sd-title">Share this:</h3><div class="sd-content"><ul><li class="share-email"><a rel="nofollow" class="share-email sd-button share-icon" href="http://telleme.wordpress.com/2010/11/27/how-to-create-interactive-web-programs-with-java/?share=email" title="Click to email this to a friend"><span>Email</span></a></li><li class="share-facebook"><a rel="nofollow" class="share-facebook sd-button share-icon" href="http://telleme.wordpress.com/2010/11/27/how-to-create-interactive-web-programs-with-java/?share=facebook" title="Share on Facebook" id="sharing-facebook-77"><span>Facebook</span></a></li><li class="share-twitter"><a rel="nofollow" class="share-twitter sd-button share-icon" href="http://telleme.wordpress.com/2010/11/27/how-to-create-interactive-web-programs-with-java/?share=twitter" title="Click to share on Twitter" id="sharing-twitter-77"><span>Twitter</span></a></li><li class="share-stumbleupon"><a rel="nofollow" class="share-stumbleupon sd-button share-icon" href="http://telleme.wordpress.com/2010/11/27/how-to-create-interactive-web-programs-with-java/?share=stumbleupon" title="Click to share on StumbleUpon"><span>StumbleUpon</span></a></li><li class="share-print"><a rel="nofollow" class="share-print sd-button share-icon" href="http://telleme.wordpress.com/2010/11/27/how-to-create-interactive-web-programs-with-java/#print" title="Click to print"><span>Print</span></a></li><li class="share-reddit"><a rel="nofollow" class="share-reddit sd-button share-icon" href="http://telleme.wordpress.com/2010/11/27/how-to-create-interactive-web-programs-with-java/?share=reddit" title="Click to share on Reddit"><span>Reddit</span></a></li><li class="share-custom"><a rel="nofollow" class="share-custom sd-button share-icon" href="http://telleme.wordpress.com/2010/11/27/how-to-create-interactive-web-programs-with-java/?share=custom-1287658434" title="Click to share"><span style="background-image:url("http://www.facebook.com");">facebook</span></a></li><li class="share-end"></li></ul></div></div></div><div class='sharedaddy sd-block sd-like jetpack-likes-widget-wrapper jetpack-likes-widget-unloaded' id='like-post-wrapper-16784990-77-53d97c9c188e6' data-src='//widgets.wp.com/likes/#blog_id=16784990&post_id=77&origin=telleme.wordpress.com&obj_id=16784990-77-53d97c9c188e6' data-name='like-post-frame-16784990-77-53d97c9c188e6'><h3 class='sd-title'>Like this:</h3><div class='likes-widget-placeholder post-likes-widget-placeholder' style='height:55px'><span class='button'><span>Like</span></span> <span class="loading">Loading...</span></div><span class='sd-text-color'></span><a class='sd-link-color'></a></div></div> <div class="linkpages"></div> </div> <small></small> <div class="postmetabottom"> <div class="tags"></div> <div class="readmore"><a href='http://telleme.wordpress.com/2010/11/27/how-to-create-interactive-web-programs-with-java/feed/'>Comments <abbr title="Really Simple Syndication">RSS</abbr> feed</a></div> </div> </div><!-- /post --> <div id="comments"> <div id="respond" class="comment-respond"> <h3 id="reply-title" class="comment-reply-title">Leave a Reply <small><a rel="nofollow" id="cancel-comment-reply-link" href="/2010/11/27/how-to-create-interactive-web-programs-with-java/#respond" style="display:none;">Cancel reply</a></small></h3> <form action="http://telleme.wordpress.com/wp-comments-post.php" method="post" id="commentform" class="comment-form"> <input type="hidden" id="highlander_comment_nonce" name="highlander_comment_nonce" value="b914d43d44" /><input type="hidden" name="_wp_http_referer" value="/2010/11/27/how-to-create-interactive-web-programs-with-java/" /> <input type="hidden" name="hc_post_as" id="hc_post_as" value="guest" /> <div class="comment-form-field comment-textarea"> <label for="comment">Enter your comment here...</label> <div id="comment-form-comment"><textarea id="comment" name="comment" title="Enter your comment here..."></textarea></div> </div> <div id="comment-form-identity"> <div id="comment-form-nascar"> <p>Fill in your details below or click an icon to log in:</p> <ul> <li class="selected" style="display:none;"> <a href="#comment-form-guest" id="postas-guest" title="Guest"> <span></span> </a> </li> <li> <a href="#comment-form-load-service:WordPress.com" id="postas-wordpress" title="WordPress.com"> <span></span> </a> </li> <li> <a href="#comment-form-load-service:Twitter" id="postas-twitter" title="Twitter"> <span></span> </a> </li> <li> <a href="#comment-form-load-service:Facebook" id="postas-facebook" title="Facebook"> <span></span> </a> </li> <li> <iframe id="googleplus-sign-in" name="googleplus-sign-in" src="https://public-api.wordpress.com/connect/?googleplus-sign-in=http%3A%2F%2Ftelleme.wordpress.com" width="24" height="24" scrolling="no" allowtransparency="true" seamless="seamless" frameborder="0"></iframe> </li> </ul> </div> <div id="comment-form-guest" class="comment-form-service selected"> <div class="comment-form-padder"> <div class="comment-form-avatar"> <a href="https://gravatar.com/site/signup/" target="_blank"> <img src="http://1.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=25&d=identicon&forcedefault=y&r=G" alt="Gravatar" width="25" class="no-grav" /> </a> </div> <div class="comment-form-fields"> <div class="comment-form-field comment-form-email"> <label for="email">Email <span class="required">(required)</span> <span class="nopublish">(Address never made public)</span></label> <div class="comment-form-input"><input id="email" name="email" type="email" value="" /></div> </div> <div class="comment-form-field comment-form-author"> <label for="author">Name <span class="required">(required)</span></label> <div class="comment-form-input"><input id="author" name="author" type="text" value="" /></div> </div> <div class="comment-form-field comment-form-url"> <label for="url">Website</label> <div class="comment-form-input"><input id="url" name="url" type="text" value="" /></div> </div> </div> </div> </div> <div id="comment-form-wordpress" class="comment-form-service"> <div class="comment-form-padder"> <div class="comment-form-avatar"> <img src="http://s2.wp.com/wp-content/mu-plugins/highlander-comments/images/wplogo.png?m=1391188133g" alt="WordPress.com Logo" width="25" class="no-grav" /> </div> <div class="comment-form-fields"> <input type="hidden" name="wp_avatar" id="wordpress-avatar" class="comment-meta-wordpress" value="" /> <input type="hidden" name="wp_user_id" id="wordpress-user_id" class="comment-meta-wordpress" value="" /> <input type="hidden" name="wp_access_token" id="wordpress-access_token" class="comment-meta-wordpress" value="" /> <p class="comment-form-posting-as pa-wordpress"><strong></strong> You are commenting using your WordPress.com account. <span class="comment-form-log-out">( <a href="javascript:HighlanderComments.doExternalLogout( 'wordpress' );">Log Out</a> / <a href="#" onclick="javascript:HighlanderComments.switchAccount();return false;">Change</a> )</span></p> </div> </div> </div> <div id="comment-form-twitter" class="comment-form-service"> <div class="comment-form-padder"> <div class="comment-form-avatar"> <img src="http://1.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=25&d=identicon&forcedefault=y&r=G" alt="Twitter picture" width="25" class="no-grav" /> </div> <div class="comment-form-fields"> <input type="hidden" name="twitter_avatar" id="twitter-avatar" class="comment-meta-twitter" value="" /> <input type="hidden" name="twitter_user_id" id="twitter-user_id" class="comment-meta-twitter" value="" /> <input type="hidden" name="twitter_access_token" id="twitter-access_token" class="comment-meta-twitter" value="" /> <p class="comment-form-posting-as pa-twitter"><strong></strong> You are commenting using your Twitter account. <span class="comment-form-log-out">( <a href="javascript:HighlanderComments.doExternalLogout( 'twitter' );">Log Out</a> / <a href="#" onclick="javascript:HighlanderComments.switchAccount();return false;">Change</a> )</span></p> </div> </div> </div> <div id="comment-form-facebook" class="comment-form-service"> <div class="comment-form-padder"> <div class="comment-form-avatar"> <img src="http://1.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=25&d=identicon&forcedefault=y&r=G" alt="Facebook photo" width="25" class="no-grav" /> </div> <div class="comment-form-fields"> <input type="hidden" name="fb_avatar" id="facebook-avatar" class="comment-meta-facebook" value="" /> <input type="hidden" name="fb_user_id" id="facebook-user_id" class="comment-meta-facebook" value="" /> <input type="hidden" name="fb_access_token" id="facebook-access_token" class="comment-meta-facebook" value="" /> <p class="comment-form-posting-as pa-facebook"><strong></strong> You are commenting using your Facebook account. <span class="comment-form-log-out">( <a href="javascript:HighlanderComments.doExternalLogout( 'facebook' );">Log Out</a> / <a href="#" onclick="javascript:HighlanderComments.switchAccount();return false;">Change</a> )</span></p> </div> </div> </div> <div id="comment-form-googleplus" class="comment-form-service"> <div class="comment-form-padder"> <div class="comment-form-avatar"> <img src="http://1.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=25&d=identicon&forcedefault=y&r=G" alt="Google+ photo" width="25" class="no-grav" /> </div> <div class="comment-form-fields"> <input type="hidden" name="googleplus_avatar" id="googleplus-avatar" class="comment-meta-googleplus" value="" /> <input type="hidden" name="googleplus_user_id" id="googleplus-user_id" class="comment-meta-googleplus" value="" /> <input type="hidden" name="googleplus_access_token" id="googleplus-access_token" class="comment-meta-googleplus" value="" /> <p class="comment-form-posting-as pa-googleplus"><strong></strong> You are commenting using your Google+ account. <span class="comment-form-log-out">( <a href="javascript:HighlanderComments.doExternalLogout( 'googleplus' );">Log Out</a> / <a href="#" onclick="javascript:HighlanderComments.switchAccount();return false;">Change</a> )</span></p> </div> </div> </div> <div id="comment-form-load-service" class="comment-form-service"> <div class="comment-form-posting-as-cancel"><a href="javascript:HighlanderComments.cancelExternalWindow();">Cancel</a></div> <p>Connecting to %s</p> </div> </div> <script type="text/javascript"> var highlander_expando_javascript = function(){ var input = document.createElement( 'input' ), comment = jQuery( '#comment' ); if ( 'placeholder' in input ) { comment.attr( 'placeholder', jQuery( '.comment-textarea label' ).remove().text() ); } // Expando Mode: start small, then auto-resize on first click + text length jQuery( '#comment-form-identity' ).hide(); jQuery( '#comment-form-subscribe' ).hide(); jQuery( '#commentform .form-submit' ).hide(); comment.css( { 'height':'10px' } ).one( 'focus', function() { var timer = setInterval( HighlanderComments.resizeCallback, 10 ) jQuery( this ).animate( { 'height': HighlanderComments.initialHeight } ).delay( 100 ).queue( function(n) { clearInterval( timer ); HighlanderComments.resizeCallback(); n(); } ); jQuery( '#comment-form-identity' ).slideDown(); jQuery( '#comment-form-subscribe' ).slideDown(); jQuery( '#commentform .form-submit' ).slideDown(); }); } jQuery(document).ready( highlander_expando_javascript ); </script> <div id="comment-form-subscribe"> <p class="comment-subscription-form"><input type="checkbox" name="subscribe" id="subscribe" value="subscribe" style="width: auto;" tabindex="6"/> <label class="subscribe-label" id="subscribe-label" for="subscribe" style="display: inline;">Notify me of follow-up comments via email.</label></p></div> <p class="form-submit"> <input name="submit" type="submit" id="comment-submit" value="Post Comment" /> <input type='hidden' name='comment_post_ID' value='77' id='comment_post_ID' /> <input type='hidden' name='comment_parent' id='comment_parent' value='0' /> </p> <p style="display: none;"><input type="hidden" id="akismet_comment_nonce" name="akismet_comment_nonce" value="53efc6acaa" /></p> <input type="hidden" name="genseq" value="1406762140" /> <p style="display: none;"><input type="hidden" id="ak_js" name="ak_js" value="65"/></p> </form> </div><!-- #respond --> <div style="clear: both"></div> </div><!-- /comments --> <div id="navigation"> <div class="alignleft">« <a href="http://telleme.wordpress.com/2010/10/29/the-life-and-time-of-micheal-jackson-1958-2009/" rel="prev">THE LIFE AND TIME OF MICHEAL JACKSON (1958-2009)</a></div> <div class="alignright"></div> </div><!-- /navigation --> </div><!-- /content --> <div id="sidebar"> <ul> <li class="boxed"> <h3>Recent entries</h3> <ul> <li><a href='http://telleme.wordpress.com/2010/11/27/how-to-create-interactive-web-programs-with-java/'>How to Create Interactive Web Programs with Java</a></li> <li><a href='http://telleme.wordpress.com/2010/10/29/the-life-and-time-of-micheal-jackson-1958-2009/'>THE LIFE AND TIME OF MICHEAL JACKSON (1958-2009)</a></li> <li><a href='http://telleme.wordpress.com/2010/10/23/the-genesis-of-the-world-part-1/'>THE GENESIS OF THE WORLD PART 1</a></li> <li><a href='http://telleme.wordpress.com/2010/10/21/what-is-the-oldest-living-thing-on-earth-who-has-the-secrets-to-longevity/'>What is the oldest living thing on earth? Who has the secrets to longevity?</a></li> <li><a href='http://telleme.wordpress.com/2010/10/20/college-girls-drinking-more-and-wearing-less-girl-born-with-4-arms-4-legs-has-successful-surgery/'>College Girls Drinking More and Wearing Less & GIRL BORN WITH 4 ARMS, 4 LEGS HAS SUCCESSFUL SURGERY</a></li> <li><a href='http://telleme.wordpress.com/2010/10/19/new-job-has-arrive-now-see-punch-for-more-details/'>NEW JOB HAS ARRIVE NOW, SEE PUNCH FOR MORE DETAILS</a></li> <li><a href='http://telleme.wordpress.com/2010/10/19/what-would-you-do-if-your-mum-walks-your-girlfriend-out-of-your-flat/'>What Would You Do If Your Mum Walks Your Girlfriend Out Of Your Flat ?</a></li> <li><a href='http://telleme.wordpress.com/2010/10/18/ifeanyi-hooks-uche/'>IFEANYI HOOKS UCHE</a></li> <li><a href='http://telleme.wordpress.com/2010/10/18/i-beg-my-husband-for-sex-%e2%80%94housewife/'>I Beg My Husband For Sex —housewife</a></li> <li><a href='http://telleme.wordpress.com/2010/10/16/picture-of-my-facebook-friends-on-telleme/'>PICTURE OF MY FACEBOOK FRIENDS ON TELLEME</a></li> </ul> </li> <li class="boxed" id="tagbox"> <h3>Browse popular tags</h3> </li> <li class="boxed"> <h3>Meta</h3> <ul> <li><a href="https://en.wordpress.com/signup/?ref=wplogin">Register</a></li> <li><a href="https://telleme.wordpress.com/wp-login.php">Log in</a></li> <li><a href="http://telleme.wordpress.com/feed/">Entries RSS</a></li> <li><a href="http://telleme.wordpress.com/comments/feed/">Comments RSS</a></li> </ul> </li> </ul> </div><!-- /sidebar --> </div><!-- /main --> <div id="footer"> <div class="foot1"> <ul> <li> <h3>Friends & links</h3> <ul> <li><a href="http://codex.wordpress.org/">Documentation</a></li> <li><a href="http://wordpress.org/extend/plugins/">Plugins</a></li> <li><a href="http://wordpress.org/extend/ideas/">Suggest Ideas</a></li> <li><a href="http://wordpress.org/support/">Support Forum</a></li> <li><a href="http://wordpress.org/extend/themes/">Themes</a></li> <li><a href="http://wordpress.org/news/">WordPress Blog</a></li> <li><a href="http://planet.wordpress.org/">WordPress Planet</a></li> </ul> </li> </ul> </div> <div class="foot2"> <ul> <li> <h3>Pages</h3> <ul> <li class="page_item page-item-2"><a href="http://telleme.wordpress.com/about/">About</a></li> </ul> </li> </ul> </div> <div class="foot3"> <ul> <li> <h3>Monthly archives</h3> <ul> <li><a href='http://telleme.wordpress.com/2010/11/'>November 2010</a></li> <li><a href='http://telleme.wordpress.com/2010/10/'>October 2010</a></li> </ul> </li> </ul> </div> </div><!-- /footer --> <div id="credits"> <div id="creditsleft"><a href="http://wordpress.com/?ref=footer_blog">Blog at WordPress.com</a>. | <a href="https://wordpress.com/themes/motion/" title="Learn more about this theme">The Motion Theme</a>.</div> <div id="creditsright"><a href="#top">[ Back to top ]</a></div> </div><!-- /credits --> </div><!-- /wrapper --> <script type='text/javascript' src='//0.gravatar.com/js/gprofiles.js?ver=201431x'></script> <script type='text/javascript'> /* <![CDATA[ */ var WPGroHo = {"my_hash":""}; /* ]]> */ </script> <script type='text/javascript' src='http://s2.wp.com/wp-content/mu-plugins/gravatar-hovercards/wpgroho.js?m=1380573781g'></script> <script> //initialize and attach hovercards to all gravatars jQuery( document ).ready( function( $ ) { if ( typeof Gravatar.init !== "function" ) { return; } Gravatar.profile_cb = function( hash, id ) { WPGroHo.syncProfileData( hash, id ); }; Gravatar.my_hash = WPGroHo.my_hash; Gravatar.init( 'body', '#wp-admin-bar-my-account' ); }); </script> <div style="display:none"> </div> <script type='text/javascript'> /* <![CDATA[ */ var HighlanderComments = {"loggingInText":"Logging In\u2026","submittingText":"Posting Comment\u2026","postCommentText":"Post Comment","connectingToText":"Connecting to %s","commentingAsText":"%1$s: You are commenting using your %2$s account.","logoutText":"Log Out","loginText":"Log In","connectURL":"http:\/\/telleme.wordpress.com\/public.api\/connect\/?action=request","logoutURL":"https:\/\/telleme.wordpress.com\/wp-login.php?action=logout&_wpnonce=1931b848f2","homeURL":"http:\/\/telleme.wordpress.com\/","postID":"77","gravDefault":"identicon","enterACommentError":"Please enter a comment","enterEmailError":"Please enter your email address here","invalidEmailError":"Invalid email address","enterAuthorError":"Please enter your name here","gravatarFromEmail":"This picture will show whenever you leave a comment. Click to customize it.","logInToExternalAccount":"Log in to use details from one of these accounts.","change":"Change","changeAccount":"Change Account","comment_registration":"0","userIsLoggedIn":"","isJetpack":"0"}; /* ]]> */ </script> <script type='text/javascript' src='http://s1.wp.com/_static/??/wp-content/js/jquery/jquery.autoresize.js,/wp-content/mu-plugins/highlander-comments/script.js?m=1403644162j'></script> <div id="bit" class="loggedout-follow-normal"> <a class="bsub" href="javascript:void(0)"><span id='bsub-text'>Follow</span></a> <div id="bitsubscribe"> <h3><label for="loggedout-follow-field">Follow “Telleme.Com”</label></h3> <form action="https://subscribe.wordpress.com" method="post" accept-charset="utf-8" id="loggedout-follow"> <p>Get every new post delivered to your Inbox.</p> <p id="loggedout-follow-error" style="display: none;"></p> <p><input type="email" name="email" value="Enter your email address" onfocus='this.value=(this.value=="Enter your email address") ? "" : this.value;' onblur='this.value=(this.value=="") ? "Enter email address" : this.value;' id="loggedout-follow-field"/></p> <input type="hidden" name="action" value="subscribe"/> <input type="hidden" name="blog_id" value="16784990"/> <input type="hidden" name="source" value="http://telleme.wordpress.com/2010/11/27/how-to-create-interactive-web-programs-with-java/"/> <input type="hidden" name="sub-type" value="loggedout-follow"/> <input type="hidden" id="_wpnonce" name="_wpnonce" value="227e9592ff" /><input type="hidden" name="_wp_http_referer" value="/2010/11/27/how-to-create-interactive-web-programs-with-java/" /> <p id='bsub-subscribe-button'><input type="submit" value="Sign me up" /></p> </form> <div id='bsub-credit'><a href="http://wordpress.com/signup/?ref=lof">Powered by WordPress.com</a></div> </div><!-- #bitsubscribe --> </div><!-- #bit --> <script type="text/javascript"> WPCOM_sharing_counts = {"http:\/\/telleme.wordpress.com\/2010\/11\/27\/how-to-create-interactive-web-programs-with-java\/":77} </script> <div id="sharing_email" style="display: none;"> <form action="/2010/11/27/how-to-create-interactive-web-programs-with-java/" method="post"> <label for="target_email">Send to Email Address</label> <input type="email" name="target_email" id="target_email" value="" /> <label for="source_name">Your Name</label> <input type="text" name="source_name" id="source_name" value="" /> <label for="source_email">Your Email Address</label> <input type="email" name="source_email" id="source_email" value="" /> <div class="recaptcha" id="sharing_recaptcha"></div><input type="hidden" name="recaptcha_public_key" id="recaptcha_public_key" value="6LcYW8MSAAAAADBAuEH9yaPcF7lWh11Iq62ZKtoo" /> <img style="float: right; display: none" class="loading" src="http://s2.wp.com/wp-content/mu-plugins/post-flair/sharing/images/loading.gif?m=1315610318g" alt="loading" width="16" height="16" /> <input type="submit" value="Send Email" class="sharing_send" /> <a href="#cancel" class="sharing_cancel">Cancel</a> <div class="errors errors-1" style="display: none;"> Post was not sent - check your email addresses! </div> <div class="errors errors-2" style="display: none;"> Email check failed, please try again </div> <div class="errors errors-3" style="display: none;"> Sorry, your blog cannot share posts by email. </div> </form> </div> <script type="text/javascript"> jQuery(document).on( 'ready post-load', function(){ jQuery( 'a.share-facebook' ).on( 'click', function() { window.open( jQuery(this).attr( 'href' ), 'wpcomfacebook', 'menubar=1,resizable=1,width=600,height=400' ); return false; }); }); </script> <script type="text/javascript"> jQuery(document).on( 'ready post-load', function(){ jQuery( 'a.share-twitter' ).on( 'click', function() { window.open( jQuery(this).attr( 'href' ), 'wpcomtwitter', 'menubar=1,resizable=1,width=600,height=350' ); return false; }); }); </script> <iframe src='http://widgets.wp.com/likes/master.html?ver=20140528#ver=20140528&mp6=1' scrolling='no' id='likes-master' name='likes-master' style='display:none;'></iframe> <div id='likes-other-gravatars'><div class="likes-text"><span>%d</span> bloggers like this:</div><ul class="wpl-avatars sd-like-gravatars"></ul></div> <script type="text/javascript"> //<![CDATA[ var jetpackLikesWidgetQueue = []; var jetpackLikesWidgetBatch = []; var jetpackLikesMasterReady = false; function JetpackLikespostMessage( message, target ) { if ( "string" === typeof message ){ try{ message = JSON.parse( message ); } catch(e) { return; } } pm( { target: target, type: 'likesMessage', data: message, origin: '*' } ); } function JetpackLikesBatchHandler() { var requests = []; jQuery( 'div.jetpack-likes-widget-unloaded' ).each( function( i ) { if ( jetpackLikesWidgetBatch.indexOf( this.id ) > -1 ) return; jetpackLikesWidgetBatch.push( this.id ); var regex = /like-(post|comment)-wrapper-(\d+)-(\d+)-(\w+)/; var match = regex.exec( this.id ); if ( ! match || match.length != 5 ) return; var info = { blog_id: match[2], width: this.width }; if ( 'post' == match[1] ) { info.post_id = match[3]; } else if ( 'comment' == match[1] ) { info.comment_id = match[3]; } info.obj_id = match[4]; requests.push( info ); }); if ( requests.length > 0 ) { JetpackLikespostMessage( { event: 'initialBatch', requests: requests }, window.frames['likes-master'] ); } } function JetpackLikesMessageListener( event ) { if ( "undefined" == typeof event.event ) return; if ( 'masterReady' == event.event ) { jQuery( document ).ready( function() { jetpackLikesMasterReady = true; var stylesData = { event: 'injectStyles' }; if ( jQuery( 'iframe.admin-bar-likes-widget' ).length > 0 ) { JetpackLikespostMessage( { event: 'adminBarEnabled' }, window.frames[ 'likes-master' ] ); stylesData.adminBarStyles = { background: jQuery( '#wpadminbar .quicklinks li#wp-admin-bar-wpl-like > a' ).css( 'background' ), isRtl: ( 'rtl' == jQuery( '#wpadminbar' ).css( 'direction' ) ) }; } if ( !window.addEventListener ) jQuery( '#wp-admin-bar-admin-bar-likes-widget' ).hide(); stylesData.textStyles = { color: jQuery( '.sd-text-color').css( 'color' ), fontFamily: jQuery( '.sd-text-color' ).css( 'font-family' ), fontSize: jQuery( '.sd-text-color' ).css( 'font-size' ), direction: jQuery( '.sd-text-color' ).css( 'direction' ), fontWeight: jQuery( '.sd-text-color' ).css( 'font-weight' ), fontStyle: jQuery( '.sd-text-color' ).css( 'font-style' ), textDecoration: jQuery( '.sd-text-color' ).css('text-decoration') }; stylesData.linkStyles = { color: jQuery( '.sd-link-color' ).css('color'), fontFamily: jQuery( '.sd-link-color' ).css('font-family'), fontSize: jQuery( '.sd-link-color' ).css('font-size'), textDecoration: jQuery( '.sd-link-color' ).css('text-decoration'), fontWeight: jQuery( '.sd-link-color' ).css( 'font-weight' ), fontStyle: jQuery( '.sd-link-color' ).css( 'font-style' ) }; JetpackLikespostMessage( stylesData, window.frames[ 'likes-master' ] ); JetpackLikesBatchHandler(); jQuery( document ).on( 'inview', 'div.jetpack-likes-widget-unloaded', function() { jetpackLikesWidgetQueue.push( this.id ); }); }); } if ( 'showLikeWidget' == event.event ) { jQuery( '#' + event.id + ' .post-likes-widget-placeholder' ).fadeOut( 'fast', function() { jQuery( '#' + event.id + ' .post-likes-widget' ).fadeIn( 'fast', function() { JetpackLikespostMessage( { event: 'likeWidgetDisplayed', blog_id: event.blog_id, post_id: event.post_id, obj_id: event.obj_id }, window.frames['likes-master'] ); }); }); } if ( 'clickReblogFlair' == event.event ) { wpcom_reblog.toggle_reblog_box_flair( event.obj_id ); } if ( 'showOtherGravatars' == event.event ) { var $container = jQuery( '#likes-other-gravatars' ); var $list = $container.find( 'ul' ); $container.hide(); $list.html( '' ); $container.find( '.likes-text span' ).text( event.total ); jQuery.each( event.likers, function( i, liker ) { $list.append( '<li class="' + liker.css_class + '"><a href="' + liker.profile_URL + '" class="wpl-liker" rel="nofollow" target="_parent"><img src="' + liker.avatar_URL + '" alt="' + liker.name + '" width="30" height="30" style="padding-right: 3px;" /></a></li>'); } ); var offset = jQuery( "[name='" + event.parent + "']" ).offset(); $container.css( 'left', offset.left + event.position.left - 10 + 'px' ); $container.css( 'top', offset.top + event.position.top - 33 + 'px' ); var rowLength = Math.floor( event.width / 37 ); var height = ( Math.ceil( event.likers.length / rowLength ) * 37 ) + 13; if ( height > 204 ) { height = 204; } $container.css( 'height', height + 'px' ); $container.css( 'width', rowLength * 37 - 7 + 'px' ); $list.css( 'width', rowLength * 37 + 'px' ); $container.fadeIn( 'slow' ); var scrollbarWidth = $list[0].offsetWidth - $list[0].clientWidth; if ( scrollbarWidth > 0 ) { $container.width( $container.width() + scrollbarWidth ); $list.width( $list.width() + scrollbarWidth ); } } } pm.bind( 'likesMessage', function(e) { JetpackLikesMessageListener(e); } ); jQuery( document ).click( function( e ) { var $container = jQuery( '#likes-other-gravatars' ); if ( $container.has( e.target ).length === 0 ) { $container.fadeOut( 'slow' ); } }); function JetpackLikesWidgetQueueHandler() { var wrapperID; if ( ! jetpackLikesMasterReady ) { setTimeout( JetpackLikesWidgetQueueHandler, 500 ); return; } if ( jetpackLikesWidgetQueue.length > 0 ) { // We may have a widget that needs creating now var found = false; while( jetpackLikesWidgetQueue.length > 0 ) { // Grab the first member of the queue that isn't already loading. wrapperID = jetpackLikesWidgetQueue.splice( 0, 1 )[0]; if ( jQuery( '#' + wrapperID ).hasClass( 'jetpack-likes-widget-unloaded' ) ) { found = true; break; } } if ( ! found ) { setTimeout( JetpackLikesWidgetQueueHandler, 500 ); return; } } else if ( jQuery( 'div.jetpack-likes-widget-unloaded' ).length > 0 ) { // Grab any unloaded widgets for a batch request JetpackLikesBatchHandler(); // Get the next unloaded widget wrapperID = jQuery( 'div.jetpack-likes-widget-unloaded' ).first()[0].id; if ( ! wrapperID ) { // Everything is currently loaded setTimeout( JetpackLikesWidgetQueueHandler, 500 ); return; } } if ( 'undefined' === typeof wrapperID ) { setTimeout( JetpackLikesWidgetQueueHandler, 500 ); return; } var $wrapper = jQuery( '#' + wrapperID ); $wrapper.find( 'iframe' ).remove(); if ( $wrapper.hasClass( 'slim-likes-widget' ) ) { $wrapper.find( '.post-likes-widget-placeholder' ).after( "<iframe class='post-likes-widget jetpack-likes-widget' name='" + $wrapper.data( 'name' ) + "' height='22px' width='68px' frameBorder='0' scrolling='no' src='" + $wrapper.data( 'src' ) + "'></iframe>" ); } else { $wrapper.find( '.post-likes-widget-placeholder' ).after( "<iframe class='post-likes-widget jetpack-likes-widget' name='" + $wrapper.data( 'name' ) + "' height='55px' width='100%' frameBorder='0' src='" + $wrapper.data( 'src' ) + "'></iframe>" ); } $wrapper.removeClass( 'jetpack-likes-widget-unloaded' ).addClass( 'jetpack-likes-widget-loading' ); $wrapper.find( 'iframe' ).load( function( e ) { var $iframe = jQuery( e.target ); $wrapper.removeClass( 'jetpack-likes-widget-loading' ).addClass( 'jetpack-likes-widget-loaded' ); JetpackLikespostMessage( { event: 'loadLikeWidget', name: $iframe.attr( 'name' ), width: $iframe.width() }, window.frames[ 'likes-master' ] ); if ( $wrapper.hasClass( 'slim-likes-widget' ) ) { $wrapper.find( 'iframe' ).Jetpack( 'resizeable' ); } }); setTimeout( JetpackLikesWidgetQueueHandler, 250 ); } JetpackLikesWidgetQueueHandler(); //]]> </script> <script type='text/javascript' src='http://s1.wp.com/wp-content/mu-plugins/akismet-3.0/_inc/form.js?m=1404442431g'></script> <script type='text/javascript'> /* <![CDATA[ */ var recaptcha_options = {"lang":"en"}; /* ]]> */ </script> <script type='text/javascript' src='http://s2.wp.com/_static/??/wp-content/js/devicepx.js,/wp-includes/js/comment-reply.min.js,/wp-content/mu-plugins/post-flair/sharing/sharing.js?m=1399919068j'></script> <script type="text/javascript"> // <![CDATA[ (function() { try{ if ( window.external &&'msIsSiteMode' in window.external) { if (window.external.msIsSiteMode()) { var jl = document.createElement('script'); jl.type='text/javascript'; jl.async=true; jl.src='/wp-content/plugins/ie-sitemode/custom-jumplist.php'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(jl, s); } } }catch(e){} })(); // ]]> </script> <script type="text/javascript"> var skimlinks_pub_id = "725X584219" var skimlinks_sitename = "telleme.wordpress.com"; </script> <script type="text/javascript" src="http://s.skimresources.com/js/725X1342.skimlinks.js"></script><script src="//stats.wp.com/w.js?22" type="text/javascript"></script> <script type="text/javascript"> st_go({'blog':'16784990','v':'wpcom','tz':'0','user_id':'0','post':'77','subd':'telleme'}); ex_go({'crypt':'UE5XaGUuOTlwaD85flAmcm1mcmZsaDhkV11YdWFnNncxc1tjZG9XVXhRVz1bVXJlWWRQcV1nUUg5Wm1aQm0saT1DaCssLGFdcTFtcEIsJmRwMG4lTVVBfFRxbVozWkJufHI4XzhPLGdlWF9uNDY9Qz9zbk01Sz1oUEpQbXo2PXR4JVZBbTV1Ti40SF1xejlyc3h3ZW5uUjY4OVJWd3c2Z1ZUTFUtbC0tWzVxLnlNVXRpWX4waHhrNVNYMnBSRUtiL2FuanZkZlNSUzYxWFMyaUY0QUVwS2Q1fltJMj12U3RLOThoJmFucC9wYndhLHxuMWouRlEuXzg4S1J8VHNjUXVYQU4uNkM3JTJIVDIuTEMscDRwTWpaVWdhVUZzQ0k='}); addLoadEvent(function(){linktracker_init('16784990',77);}); </script> <noscript><img src="http://pixel.wp.com/b.gif?v=noscript" style="height:0px;width:0px;overflow:hidden" alt="" /></noscript> <script> if ( 'object' === typeof wpcom_mobile_user_agent_info ) { wpcom_mobile_user_agent_info.init(); var mobileStatsQueryString = ""; if( false !== wpcom_mobile_user_agent_info.matchedPlatformName ) mobileStatsQueryString += "&x_" + 'mobile_platforms' + '=' + wpcom_mobile_user_agent_info.matchedPlatformName; if( false !== wpcom_mobile_user_agent_info.matchedUserAgentName ) mobileStatsQueryString += "&x_" + 'mobile_devices' + '=' + wpcom_mobile_user_agent_info.matchedUserAgentName; if( wpcom_mobile_user_agent_info.isIPad() ) mobileStatsQueryString += "&x_" + 'ipad_views' + '=' + 'views'; if( "" != mobileStatsQueryString ) { new Image().src = document.location.protocol + '//pixel.wp.com/g.gif?v=wpcom-no-pv' + mobileStatsQueryString + '&baba=' + Math.random(); } } </script></body> </html>