Java Tip 114: Add ghosted drag images to your JTrees

When using drag and drop, a drag image is a useful visual reminder of what is actually being dragged. However on some platforms, notably Microsoft's Win32, the drag image requested in your Java program is ignored, depriving the user...


Java Tip 113: Identify subclasses at runtime

Java Reflection provides a lot of information about a given class at runtime; you can easily know all its super classes, implemented interfaces, methods, constructors, fields, and so on. But in some cases, you may want to know all the...


Java Tip 112: Improve tokenization of information-rich strings

In this article, you'll take advantage of the commonly used StringTokenizer class to perform better tokenization of complicated and information-rich strings.


Java Tip 110: Implement the Observer pattern with EJBs

In most J2EE systems, it is desirable to have factories or managers (implemented as stateless session beans) that fire appropriate events. EJB containers handle the demand for stateless session beans by creating as many instances of...


Java Tip 109: Display images using JEditorPane

To display HTML in a JEditorPane, you would normally specify a URL that sets the document base of the HTMLDocument. However, if the HTML text is not stored in a file locally or on the Web, you cannot set the HTMLDocument document...


Java Tip 108: Apply RMI autogeneration

Using the tool in this tip, you can make objects written with local semantics remote. The tool creates remote interfaces that have roughly the same method signatures as the local interfaces. These generated interfaces form a layer...


Java Tip 107: Maximize your code reusability

Don't give up on your efforts to write reusable code! This tip outlines three ways you can modify your existing code to increase its reusability.


Java Tip 105: Mastering the classpath with JWhich

The Java classpath has always been a source of frustration and confusion, despite its seemingly simple concepts. This article demonstrates a simple tool for unambiguously identifying which Java class in your classpath the class loader...


Java Tip 103: Send HTTP requests for serialized objects

An HTTP Object Channel between a Web server and an applet (or any kind of Java Web client) would be very useful. Dynamic data could be delivered to the Web client directly (in a serialized form) and through firewalls. Those data could...


Java Tip 102: Add multiple JTable cell editors per column

By default, the Swing JTable component allows only one editor type per column. In most cases, all cells in a JTable column are of the same class and thus can be edited with the same editor type. However, occasionally you may want a...


Java Tip 101: An alternative way for applet-to-applet communication

You might think that your only option for letting applets communicate with each other is to use the getApplet method. Unfortunately, the getApplet method only returns applets on the same HTML page as the calling applet, limiting the...


Java Tip 100: Add a history mechanism to JFileChooser

Many applications provide a history mechanism for recently used files or visited Websites. This tip enhances the Swing JFileChooser component by using the accessory feature to implement a history mechanism for visited directories....


Java Tip 99: Automate toString() creation

Experienced Java developers know the importance of well-written toString methods. It's much easier to log and debug objects that can be viewed in human-readable form; this is particularly the case when working with distributed...


Java Tip 98: Reflect on the Visitor design pattern

The Visitor pattern is often used to separate the structure of an object collection from the operations performed on that collection. For example, it can separate the parsing logic in a compiler from the code generation logic. By...


Java Tip 97: Add drag and drop to your JTrees

Among other features, Java 2 has provided Java programmers with the ability to build drag and drop into their GUI components. However, in components such as the JTree, the drag-and-drop implementation is not intuitive. This tip guides...


Java Tip 96: Use HTTPS in your Java client code

Using HTTPS (Hypertext Transfer Protocol Secure) isn't as obvious as you might think. If you've ever tried to implement secure communication between a Java client and an HTTPS server, you've probably discovered that the standard...


Java Tip 95: Load classes behind the scenes

Due to Java's runtime class loading, you can encounter many uncomfortable pauses when loading a Java applet or application. For many programmers, that is an unfamiliar performance problem, and the common solutions leave much to be...


Java Tip 93: Add a file finder accessory to JFileChooser

How many times have you selected the Open File menu item in an application only to discover that you can't find the file you need? This tip demonstrates how to add a threaded file finder accessory to JFileChooser similar in appearance...


Java Tip 94: How to open a non-HTML document from a servlet

Java servlet programming provides an easy way to send HTML files to client Web browsers. However, many Websites today provide access to documents that are not in HTML, including Adobe PDF, Microsoft Word, and Microsoft Excel files....


Java Tip 92: Use the JVM Profiler Interface for accurate timing

Most Java programs are multithreaded, either by design or because the garbage collector runs on its own thread. This makes performance analysis difficult because you can never be sure how much CPU time the thread scheduler actually...


Load More