1 import org.swixml.SwingEngine;
2 
3 import javax.swing.JList;
4 import java.awt.event.WindowAdapter;
5 import java.awt.event.WindowEvent;
6 import javax.swing.event.ListSelectionListener;
7 import javax.swing.event.ListSelectionEvent;
8 
9 public class HelloList extends WindowAdapter {
10  
11  private JList mList; /*instantiated by swixml when rendering the UI */
12
13  private HelloList() throws Exception {
14    new SwingEngine( this ).render( "./xml/hellolist.xml" ).setVisible( true );
15    System.out.println( mList.size() ); 
16    mList.addListSelectionListener( new ListSelectionListener() {
17      public void valueChanged( final ListSelectionEvent e) {
18          System.out.println( mList.getSelectedValue() ); 
19      }
20    }); 
21  }
22
23  /**
24     * Invoked when a window is in the process of being closed.
25     * The close operation can be overridden at this point.
26     */
27    public void windowClosing(final WindowEvent e) {
28      super.windowClosing(e);
29      System.exit(0);
30    } 
31  
32  /** Makes the class bootable */
33  public static void main( final String[] args ) throws Exception {
34    new HelloList();
35  }
36  
37}