KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > HelloMac


1
2 import org.swixml.SwingEngine;
3
4 import javax.swing.*;
5 import java.awt.event.ActionEvent JavaDoc;
6 import java.awt.event.WindowEvent JavaDoc;
7 import java.awt.event.WindowAdapter JavaDoc;
8 import java.io.IOException JavaDoc;
9
10 import 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:wolf@paulus.com">Wolf Paulus</a>
17  * @version $Revision: 1.1 $
18  *
19  * @since swixml 1.1
20  */

21 public class HelloMac extends WindowAdapter JavaDoc {
22   private SwingEngine swix;
23
24   private HelloMac() throws Exception JavaDoc {
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 JavaDoc 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 JavaDoc e ) {
38       try {
39         FileManager.openURL("http://www.swixml.org/apidocs/index.html");
40       } catch (IOException JavaDoc e1) {
41         e1.printStackTrace();
42       }
43     }
44   };
45
46   public Action actionExit = new AbstractAction() {
47     public void actionPerformed( ActionEvent JavaDoc 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 JavaDoc e ) {
58     super.windowClosing( e );
59     System.exit(0);
60   }
61
62   //
63
// Make the class bootable
64
//
65
public static void main( String JavaDoc[] args ) throws Exception JavaDoc {
66     new HelloMac();
67   }
68 }
Popular Tags