home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 14 / IOPROG_14.ISO / soft / sdkjava / sdkjava.exe / SDKJava.cab / AFC102 / Samples / Puzzle15 / Src / Puzzle15.java next >
Encoding:
Java Source  |  1998-03-05  |  1.6 KB  |  72 lines

  1. //
  2. // (c) 1997 Microsoft Corporation.    All rights reserved.
  3. //
  4. import java.awt.Insets;
  5. import java.awt.Event;
  6. import com.ms.ui.*;
  7. import com.ms.fx.*;
  8.  
  9. // Awt wrapper for UIApplet
  10. public class Puzzle15 extends AwtUIApplet
  11. {
  12.     public Puzzle15() { super(new Pz15Applet()); }
  13.  
  14.     // Application CODE
  15.     public static void main(String args[])
  16.     {
  17.         try { new Pz15Frame(); } catch (Exception e) { e.printStackTrace(); }
  18.     }
  19. }
  20.  
  21. // Applet CODE
  22. class Pz15Applet extends UIApplet
  23. {
  24.     private Pz15ControlPanel ctrl;
  25.  
  26.     public void init()
  27.     {
  28.         try {
  29.             setLayout(new UIBorderLayout(0, 0));
  30.             setFont(new FxFont("Dialog", FxFont.PLAIN, 14));
  31.             ctrl = new Pz15ControlPanel(this, null);
  32.             add(ctrl, "Center");
  33.         } catch (Exception e) { e.printStackTrace(); }
  34.     }
  35.  
  36.     public void start() { ctrl.initialize(); }
  37.  
  38.     public void stop() { ctrl.hideProperties(); }
  39.  
  40.     //
  41.     // User may switch to another program running in his system, when he comes back,
  42.     //    applet will get focus, need to give it to the gameboard.
  43.     //
  44.     public void requestFocus() { ctrl.requestFocus(); }
  45. }
  46.  
  47. // Application CODE
  48. class Pz15Frame extends UIFrame
  49. {
  50.     public Pz15Frame()
  51.     {
  52.         super("Puzzle15 Application");
  53.         setBackground(java.awt.Color.lightGray);
  54.         setLayout(new UIBorderLayout(0, 0));
  55.         setFont(new FxFont("Dialog", FxFont.PLAIN, 14));
  56.         Pz15ControlPanel ctrl = new Pz15ControlPanel(null, this);
  57.         add(ctrl, "Center");
  58.         setSize(360, 475);
  59.         setVisible(true);
  60.         ctrl.initialize();
  61.     }
  62.  
  63.     public boolean handleEvent(Event evt)
  64.     {
  65.         switch (evt.id)
  66.         {
  67.             case Event.WINDOW_DESTROY: System.exit(0); return true;
  68.             default: return super.handleEvent(evt);
  69.         }
  70.     }
  71. }
  72.