Viewer Classes

What are Viewer Classes?

Viewer Classes are Java Applications that can be run from Packafied directly. They usually allow editing of a certain file type.

Writing a Viewer Class

If you are a Java application developer, it should be fairly easy to allow your application to become a Packafied Viewer Class.

The first step is to make the main part of the program implement the FileViewer interface. See the documentation for FileViewer for more info. This info is in the developer directory.

Next, your main class must contain these two static methods.

/*
* Returns a description of this viewer. It is advisable to put
* the title and then the version.
*/
public static String getFileViewerDescrip()

/*
* Returns an instance of a FileViewer object that can be used by
* Packafied.
*/
public static FileViewer getFileViewer()

Usually, if the class that contains the above static methods is the same class that you have made implement the FileViewer interface, your getFileViewer() method will look something like this:


public class MyApp extends Frame
{
    public static void main(String[] args)
    {
        MyApp app = new MyApp();
        app.setSize(100,100);
        app.show();
    }

    public MyApp()
    {
        super("My Title");
        
        //...Add components to the window...
  
    }

    public static String getFileViewerDescrip()
    {
        return("FileViewer App Demonstration 1.0");
    }

    /*
     * Just like the main() method!
     */
    public static FileViewer getFileViewer()
    {
        MyApp app = new MyApp();
        app.setSize(100,100);
        app.show();

        return(app);
    }
}