See also my pages for:   JavaScript
A random quote  (click in quote area for another quote)
(Here's the source for this applet.)

VisualAge for Java Tips Links Newsgroups

  Java is a language developed by Sun Microsystems that runs in a single Java Virtual Machine (JVM), which enables any system that has a JVM to implement Java, making it extremely portable and versatile. Java is much more than just an object-oriented programming language, and it can be used in a variety of ways ranging from applets or servlets running in web browsers, to JavaServer Pages (JSPs), to full-blown standalone applications. For a good description of the language, read JavaSoft's classic "White Paper". Don't confuse Java with JavaScript (see Danny Goodman article for quick explanation).

Professionally, one of the languages I have used is Java, primarily creating applets, and also some servlets and JSPs. What I want to do on this page is to provide some Java information, show a few solutions, and hopefully keep others from making the same mistakes and experiencing the same frustration I did before I got things to work. I haven't used Java in a few years, so some of these things may be a little out of date.

The Random Quote applet above is something I created for a project in a Java class I took at Northeastern in 1997.

VisualAge for Java Discontinued by IBM
  VisualAge for Java has been taken off the market by IBM, so I have removed my VaJava tips section. If I start doing Java development again I will replace this section.

Top of page

Java tips
  This section is not intended to teach how to code Java. There is plenty of other good reference material out there for that. I just want to share some simple ways to do things that I have picked up or developed that may save you some development time of your own.

  Changing the shape of the mouse pointer

Sometimes in an applet you may want to momentarily implement a "wait" pointer (typically an hourglass) to inform the user that some process is running in the background. In Java examples and how-to's I've seen entire methods being created to perform this simple task when all that is needed is a single line of code.

// Change pointer to wait shape this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); //... background //... processing //... occurs here ... // Change pointer back to default shape this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));

I use this technique to manipulate the pointer in my Random Quote applet at the top.

  Printing from Java

Here are several links, Printing with Printables (Sun), Printing in Java (JavaWorld), and Java ™ 2 Environment Printing API ( with good information that helped me create the following 2 classes that I use as models whenever I want to print from applets. Java Printing API has sample code and also a nice diagram showing the flow of the API process.

MyPrint.class & PrintListing.class

The first class, MyPrint, is invoked to create the printer job and display the print dialog, and if the user clicks the OK button, it invokes the second class, PrintListing, to do the actual printing. The way I typically use this is to build an SQL ResultSet that is used to format rows in a ScrollPaneTable in an applet window containing a Print button, and as each row is added to the display it is also loaded into a Vector. When the Print button is clicked, MyPrint.printReport() is called with the Vector, which is subsequently passed to PrintListing. The code in MyPrint could be included in the applet, but I found the applet screen refreshed cleaner after the print dialog closed if it was invoked from a separate class. I also use the wait pointer technique described above when the Print button is pressed.

  Right-justifying numeric values in columns

Here is a technique I use to right-justify numbers in columns, for instance, to align decimal points for amounts. The key here is to replace leading zeros with a blank character that will not be trimmed. I created this character to store in my placeHolder variable by holding down the alt-key and pressing 0160 on the keypad. (Different operating systems may need a different non-blank character, I know mine appears as a ? on a Macintosh.)

String sNumber = Integer.toString(someInt); int len = sNumber.length(); String placeHolder = " ";  // this blank is really alt-0160 boolean startedMove = false; String sResult = " "; for (int j = 0; j < len; j++) { String n = sNumber.substring(j, j+1); if (!n.equals("0") || startedMove || (j == len-1)) { sResult = sResult.trim() + n; startedMove = true;  // move all characters from now on } else { sResult = sResult.trim() + placeHolder; } }

The variable sResult now contains the zero-suppressed, right-justified value of someInt. Use with a fixed-width font in an applet or report.

Top of page

Java links
     Sun - The Source for Java Developers
     Examplets from The Java Developers Almanac
     Java 2 Platform, Standard Edition (J2SE)
Just Java - Java Software, FAQs, Books – Peter van der Linden's site
Java & Internet Glossary – Roedy Green's cool site
Workbench: Programming, publishing, politics, and popes(?) - Rogers Cadenhead
Java Lecture Notes – from author/teacher Elliotte Rusty Harold
     JavaServer Pages
JSP Insider – a good site for JavaServer Page developers
JavaServer Pages(TM) Technology – Sun's JSP page
Netscape DevEdge – Netscape's Java and JavaScript coding standards here
Java Applets
The FAQ List
Gamelan: Earthweb's Java Directory
JavaWorld Magazine
Visual J++ Start Page
Welcome to JARS.COM
Java FAQ Archives
The Swing/JFC FAQ
Java Coffee Break
The Java Lobby
JCreator - Free Java IDE – this is nice; and free!
Languages for the Java VM
Java Tutorial

Top of page

Java newsgroups
  I used to have all the Java usenet groups listed here but they don't seem to function in browsers anymore, so I am just providing a link to Google Groups, where they are offered in a web format.* at Google Groups

   There are more newsgroups on my Programming page.