componentref

Pavan Sara <[email protected]> Fri, 14 Jan 2005 13:59:16 +0100
Newsgroups gmane.comp.java.luxor-xul.user
Message-ID <[email protected]>
Hi,
I am trying to build a Java application (NOT an applet) and I need to 
insert external component in my JFrame (JCalendar in my example).

In the .xul file I inserted the following line:

    <componentref id="calend"/>


and this is the main class file:

----------------------------------------
public class MyTest extends JFrame
{
    public JDesktopPane pane = new JDesktopPane();
    public JInternalFrame internal = new JInternalFrame();
    public JCalendar calendar = new JCalendar(JCalendar.DISPLAY_DATE, 
false);

    public MyTest()
    {
        super("MyTest");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        Status.addListener(new StatusConsole());

        final XulManager xul = XulManager.getXulManager();
    xul.setResourceLoader(new ChromeFileResourceLoader(new 
File("/home/itl02568/download/xul/xul/")));
        MyComp comp = new MyComp(calendar, xul);
        xul.load();
        XulAction new_click = new XulAction("new_click")
        {
            public void execute()
            {
            }
        };
        XulAction open_click = new XulAction("open_click")
        {
            public void execute()
            {
                pane.remove(internal);

                internal.getContentPane().add(xul.lookupBox("pm"));
                internal.setVisible(true);
                pane.add(internal);
            }
        };

        setJMenuBar(xul.lookupMenuBar("mainMenubar"));
        getContentPane().add(xul.lookupToolBar("mainToolbar"), 
BorderLayout.NORTH);
        getContentPane().add(pane);

        setVisible(true);
    }

    public static void main(String argv[])
    {
        try
        {
            new MyTest();
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }
}

class MyComp extends XulForm
{
    JCalendar calend;
    public MyComp(JCalendar calend, XulManager xul)
    {
        super("MyComp");
        this.calend = calend;
        addComponent("calend", calend);
        setup();
    }
    public void init()
    {
        addComponent("calend", calend);
    }
}
----------------------------------------

The problem is that I need to use addComponent to insert the JCalendar 
(calend), but if I extend JFrame I cannot extend XulForm too.
So, I created a new class (MyComp) that extends XulForm, in which I call 
the method addComponent.

But when I run the application, I get the following error:

    SEVERE: *** xul error: box 'MyComp' not found
    Jan 14, 2005 9:05:31 AM houston.Logger error
    SEVERE: *** xul error: form 'MyComp' not found; cannot setup form

I think the problem is in the instruction

        super("MyComp");

but I really don't know ho to make in work.

Thanks in advance!
S.


-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt