How can I use alignment viewer in my programs?

Hello,

I want to use alignment viewing capability and other features of Jalview
in my programs. For this, i create new classes encapsulation necessary Jalview
components. However i have hard time to decide which components
to use and what to change. Below is an example of my way of using Jalview.
I will be glad if someone points out the steps of doing this right.

Huseyin

import jalview.datamodel.Alignment;
import jalview.gui.AlignFrame;
import jalview.io.AlignFile;
import jalview.io.ClustalFile;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.io.IOException;

import javax.swing.JFrame;

/*
* Test to see if i can use Jalview's alignment displayer
* independently.
*/
public class JalviewTest
{
    public static void main(String[] args)
    {
        JalviewTest test = new JalviewTest();
        test.createAndShowGUI();
    }
       private void createAndShowGUI()
    {
        JalviewFrame frame = new JalviewFrame(new File("C:\\HDV.aln")); frame.pack();
        frame.setVisible(true);
        frame.setSize(400,400);
        frame.addWindowListener(new WindowAdapter()
        {
            public void windowClosing(WindowEvent e)
            {
                System.exit(0);
            }
        });
    }

    class JalviewFrame extends JFrame
    {
        AlignFrame alignFrame ; File alignmentFile ;
               private static final long serialVersionUID = 1L;
               public JalviewFrame(File file)
        {
            super(file.getName());
            alignmentFile = file;
            init();
        }

        private void init()
        {
            AlignFile afile = null;
            try
            {
                afile = new ClustalFile(alignmentFile.getAbsolutePath(),"File");
            } catch (IOException e)
            {
                e.printStackTrace();
                return;
            }
                       Alignment alignment = new Alignment(afile.getSeqsAsArray()); afile.addAnnotations(alignment); alignFrame = new AlignFrame(
                    alignment,
                    AlignFrame.DEFAULT_WIDTH,
                    AlignFrame.DEFAULT_HEIGHT);
            this.setContentPane(alignFrame.getContentPane());
            this.setJMenuBar(alignFrame.getJMenuBar()); }
    }
}