1 
2 import org.swixml.SwingEngine;
3 
4 import javax.swing.*;
5 import java.awt.event.ActionEvent;
6 import java.awt.event.WindowEvent;
7 import java.awt.event.WindowAdapter;
8 import java.io.IOException;
9 
10import com.apple.eio.FileManager;
11
12/**
13 * The HelloMac class shows a couple of the Mac specifics exposed
14 * <code>HeeloMac</code> renders the GUI, which is described in hellomac.xml
15 *
16 * @author <a href="mailto:[email protected]">Wolf Paulus</a>
17 * @version $Revision: 1.1 $
18 *
19 * @since swixml 1.1
20 */
21public class HelloMac  extends WindowAdapter {
22  private SwingEngine swix;
23
24  private HelloMac() throws Exception {
25    swix= new SwingEngine( this );
26    swix.render( "xml/hellomac.xml" );    
27    swix.getRootComponent().setVisible( true );
28  }
29
30  public Action actionAbout = new AbstractAction() {
31    public void actionPerformed( ActionEvent e ) {
32      JOptionPane.showMessageDialog( swix.getRootComponent(), "This is the Mac OS X Example." );
33    }
34  };
35
36  public Action actionHelp = new AbstractAction() {
37    public void actionPerformed( ActionEvent e ) {
38      try {
39        FileManager.openURL("http://www.swixml.org/apidocs/index.html");
40      } catch (IOException e1) {
41        e1.printStackTrace();
42      }
43    }
44  };
45
46  public Action actionExit = new AbstractAction() {
47    public void actionPerformed( ActionEvent e ) {
48      JOptionPane.showMessageDialog( swix.getRootComponent(), swix.getLocalizer().getString("mis_Exit"));
49      HelloMac.this.windowClosing(null);
50    }
51  };
52
53  /**
54   * Invoked when a window is in the process of being closed.
55   * The close operation can be overridden at this point.
56   */
57  public void windowClosing( WindowEvent e ) {
58    super.windowClosing( e );
59    System.exit(0);
60  }
61
62  //
63  //  Make the class bootable
64  //
65  public static void main( String[] args ) throws Exception {
66    new HelloMac();
67  }
68}