Last Modified: 5/10/2016 |
Java |
(Please click on PENCELAND.com above to go to my main page.)
I am no longer updating this page so it may get outdated. |
|
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.
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 has been taken off the market by IBM, so I have removed my VaJava tips section. If they bring it back again I will replace this section. |
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. |
Printing from Java
Here are several links, Printing with Printables (Sun), Printing in Java (JavaWorld), and Java 2 Environment Printing API (JavaSource.com) 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. |
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.
I use this technique to manipulate the pointer in my Random Quote applet at the top. |
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.)
The variable sResult now contains the zero-suppressed, right-justified value of someInt. Use with a fixed-width font in an applet or report. |
Sun |
Individuals |
JavaServer Pages |
Netscape |
Assorted |
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. |
There are more newsgroups on my Programming page.