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

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