Home
Categories
Dictionnary
Download
Project Details
Changes Log
FAQ
License

XUL scripts integration



There are two different ways to integrate XUL scripts in your Java application:
  • By integrating the Swing component representing the XUL script (the root widget) in your own Swing GUI
  • By bridging the scripts with your application code

Integrating the Swing component

Installing in a frame or window

The most simple way to integrate your XUL scripts Swing components in your Swing Java application is by calling one of the following methods: These methods will put the XUL documents root widgets in the JFrame content pane, and add the menus and toolbars of the documents in the frame.

If you defined in your install(JFrame parent, boolean scrollable, boolean hasLoggerArea, int loggerRows) that you wanted to have a logger area, it will also add a logger at the bottom of the frame.

Note that this way of Swing integration suppose that you don't want to put anything else in your JFrame.

For example with this code:

      DefaultScriptManager manager = new DefaultScriptManager();
      manager.setScriptLogger(new DefaultSwingScriptLogger());

      manager.addXULScript(file);
      // the second (boolean) argument specifies that the Swing component will be scrollable
      // the third (boolean) argument specifies that there will be a logger
      // the last (int) argument specifies the number of lines of the logger    
      manager.install(this, true, true, 10);      

We will have this result:


installlogger

Managing root widgets independantly

If you want to control how you will integrate your root widgets in your Swing GUI, you can directly get the root widgets associated with each XULDocument. The XULDocument.getRootComponent() return the root Swing widget ssociated with each document. Then you can integrate it as you want in your own Swing hierarchy.

To manage the menus and toolbars, you can get them through the following methods:

Bridging the scripts with your application code

To bridge your scripts in your application code, you can:

Categories: integration

Copyright 2008-2020 Herve Girod. All Rights Reserved. Documentation and source under the LGPL licence