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

  1. //
  2. // (c) 1998 Microsoft Corporation.  All rights reserved.
  3. //
  4. import java.awt.Event;
  5. import java.awt.Dimension;
  6. import com.ms.ui.*;
  7. import com.ms.fx.*;
  8.  
  9. class Pz15PropGame extends UIPropertyPage implements Pz15Consts, IFxTextConstants
  10. {
  11.     private Pz15Options props;
  12.     private UICheckButton cpu;
  13.     private UISpinnerEdit scrambler;
  14.  
  15.     public Pz15PropGame(Pz15Options props)
  16.     {
  17.         super(props);
  18.         this.props = props;
  19.     }
  20.  
  21.     public boolean addContent()
  22.     {
  23.         scrambler = new UISpinnerEdit(UISpinner.RAISED, 
  24.                                         UISpinnerEdit.BORDER | UISpinnerEdit.CENTER,
  25.                                         MIN_SCRAMBLE,MAX_SCRAMBLE, 10,1, props.numscramble);
  26.         // Get Buddy
  27.         IUIComponent comp = scrambler.getLayoutComponent(UISpinner.BUDDY);
  28.         UIEdit edit;
  29.         if ( comp instanceof UIEdit ) { // it very well better be
  30.             edit = (UIEdit)comp;
  31.             edit.setMaxBufferSize(3); edit.setVertAlign(vtaCenter);
  32.             edit.setFont(new FxFont("Dialog", FxFont.BOLD, 14));
  33.         }
  34.  
  35.         UIGroup scramble = new UIGroup("Scrambling");
  36.         scramble.setLayout(new UIBorderLayout());
  37.         scramble.add(new SDKInsetPanelBL(scrambler, 14,60,14,60));
  38.  
  39.         addAt(scramble, 6, 10, new Dimension(189, 50));
  40.  
  41.         UIGroup cpugr = new UIGroup("Competition");
  42.         cpu = new UICheckButton("Have computer determine an optimum solution");
  43.         cpugr.setLayout(new UIBorderLayout()); cpugr.add(cpu, "center");
  44.         if ( props.cpuactive )
  45.             cpu.setChecked(true);
  46.  
  47.         addAt(cpugr, 6, 70, new Dimension(189, 50));
  48.  
  49.         return true;
  50.     }
  51.  
  52.     public boolean action(Event e, Object arg)
  53.     {
  54.         if ( (arg instanceof UICheckButton) && (arg == cpu) )
  55.             setApplyable(true);
  56.         return super.action(e, arg);
  57.     }    
  58.  
  59.     public boolean handleEvent(Event e)
  60.     {
  61.         switch ( e.id ) {
  62.         case Event.SCROLL_ABSOLUTE:
  63.             if ( e.arg instanceof UISpinnerEdit )
  64.                 scrambler.setScrollPos(scrambler.getScrollPos());
  65.             // FALL THROUGH
  66.         case Event.SCROLL_LINE_DOWN:
  67.         case Event.SCROLL_LINE_UP:
  68.             if ( e.arg instanceof UISpinnerEdit )
  69.                 setApplyable(true);
  70.             break;
  71.         }
  72.         return(super.handleEvent(e));
  73.     }
  74.     
  75.     public boolean doApplyAction()
  76.     {
  77.         props.numscramble = scrambler.getScrollPos();
  78.         props.cpuactive = cpu.isChecked();
  79.         return true;
  80.     }
  81. }
  82.