1 
2 import org.swixml.SwingEngine;
3 
4 import javax.swing.*;
5 import java.awt.event.ActionEvent;
6 
7 public class HelloWorld {
8   /** submit counter */
9   private int clicks;
10
11  /** JTextField member gets instantiated through Swixml (look for id="tf" in xml descriptor) */
12  public JTextField tf;
13
14  /** Jlabel to display number of button clicks */
15  public JLabel cnt;
16
17  /** Action appends a '#' to the textfields content.  */
18  public Action submit = new AbstractAction() {
19    public void actionPerformed( ActionEvent e ) {
20      tf.setText( tf.getText() + '#' );
21      cnt.setText(String.valueOf( ++clicks ));
22    }
23  };
24
25  /** Renders UI at construction */
26  private HelloWorld() throws Exception {
27    new SwingEngine( this ).render( "xml/helloworld.xml" ).setVisible( true );
28  }
29
30  /** Makes the class bootable */
31  public static void main( String[] args ) throws Exception {
32    new HelloWorld();
33  }
34}
35