When you want to use a COM object from within a Java applet, you must first create a set of .class files that describe the component’s interfaces. Microsoft Developer Studio provides a tool that simplifies this task. Go to the Tools menu and select Java Type Library Wizard. The dialog box that appears displays a list of the COM objects registered on your system; an example of this is shown in Figure 5-1.
Figure 5-1. The Java Type Library Wizard.
In the figure, the box next to the IE Super Label component is checked. Super Label is an ActiveX control provided in Microsoft Internet Explorer; it allows the rotation and curving of text within a boundary box. Later in this chapter, I’ll use Super Label from a Java application. So I click the OK button, and the output window displays the information shown in Figure 5-2.
Figure 5-2. Output from the Java Type Library Wizard.
The Java Type Library Wizard creates a class for each of the COM interfaces exposed by Super Label. The wizard assumes that all registered COM objects can be trusted (trust is a concept I’ll discuss later in this book), so it creates the classes as a Java package named ielabel under the directory \windows\java\trustlib. In the output window, you can see the statement
import ielabel.*;
which will link your Java code to these COM interface classes. Also in that directory is a file that describes the interfaces created; if you were to double-click on the line about “summary.txt,” a file like this one would appear.
public class ielabel/IeLabel extends java.lang.Object
{
}
public interface ielabel/DIeLabelEvents
extends com.ms.com.IUnknown
{
public abstract void Change();
public abstract void MouseUp(short, short, int, int);
public abstract void Click();