How to create a component?
Hover your mouse over the 's to see the tips.

Java code for the component

package ui.component.menu;

import java.io.IOException;
import java.io.InputStream;

import xkit.XKit;
import cize.ComponentBox;

import ui.component.about.AboutCtrl;
/**
 @author Koen Roevens
 */
public class Menu {

  /**
   * Constructor
   */
  private XKit x;
  private Object parent;
  public Menu(XKit xthrows IOException {
    this(x, null, null);
  }
  public Menu(XKit x, ComponentBox c, Object parentthrows IOException {
    this.x = x;
    this.parent = parent;
    if (c != null) {
      c.parseComponent(getStream(), this, parent);
    else {
      x.add(x.parse(getStream()this));      
    }
  }  
  private InputStream getStream () throws IOException {
    return getClass().getResourceAsStream("menu.xml");
  }
  
  /**
   * Listener method
   */
  public void exit() {
    System.exit(0);
  }
  
  /**
   * Listener method
   */
  public void defaultTheme() {
    x.setColors(0xe6e6e60x0000000xffffff,
      0x9090900xb0b0b00xededed0xb9b9b90x89899a0xc5c5dd);
  }
  
  /**
   * Listener method
   */
  public void yellowTheme() {
    x.setColors(0xeeeecc0x0000000xffffff,
      0x9999660xb0b0960xededcb0xcccc990xcc66000xffcc66);
  }
  
  /**
   * Listener method
   */
  public void blueTheme() {
    x.setColors(0x6375d60xffffff0x7f8fdd,
      0xd6dff50x9caae50x6666660x0033990xff33330x666666);
  }
  
  /**
   * Listener method
   */
  public void about() {
    new AboutCtrl(x, 
             x.getString(parent,"description")
             x.getString(parent,"author")
             x.getString(parent,"email"));
  }  
}
Java2html

Xml for the component

<?xml version="1.0" encoding="ISO-8859-1"?>
<menubar weightx="1">
  <menu text="File">
    <menuitem text="Exit" action="exit" icon="/icon/exit.png"/>
  </menu>
  <menu text="Theme">
    <checkboxmenuitem text="Default" group="theme" selected="true" action="defaultTheme" />
    <checkboxmenuitem text="Sandstone" group="theme" action="yellowTheme" />
    <checkboxmenuitem text="Ocean" group="theme" action="blueTheme" />
  </menu>
  <menu text="Help">
    <menuitem text="About" action="about" icon="/icon/info.png"/>
  </menu>
</menubar>

Java code to register the component

package ui.component.menu;

import thinclet.component.poormans.StaticComponentFactory;
import sbox.StaticBox;

/**
 @author Koen Roevens
 */
public abstract class RegisterMenu {
  // Register the component
  static {
    try {
      ComponentBox cbox = (ComponentBox)StaticBox.getTheBox().lookUp(ComponentBox.LOOK_UP_NAME);
      Hashtable properties = new Hashtable();
      properties.put(String.classnew String[]{"description""author""email"});
      cbox.registerComponentType("menu"
                     Menu.class
                     properties,
                     "menubar");
    catch (IllegalArgumentException iae) {
      System.err.println(Menu.class.getName() ".static: "+ iae.getMessage());
    }      
  }
}
Java2html