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

  1. //
  2. // (c) 1998 Microsoft Corporation.  All rights reserved.
  3. //
  4. import java.awt.Event;
  5. import com.ms.ui.*;
  6. import com.ms.fx.*;
  7.  
  8. public class LCWizard extends UIWizard implements LCConsts
  9. {
  10.     private WZValue firststep;
  11.     private LCCallbacks callback;
  12.     private IUIWizardStep finish;
  13.  
  14.     public LCWizard(UIFrame frame, LCCallbacks callback, IUIWizardStep finish)
  15.     {
  16.         super(frame, "LoanCalc - A Loan Calculator");
  17.         setFont(new FxFont("Dialog", FxFont.PLAIN, 14));
  18.         firststep = null;
  19.         this.callback = callback;
  20.         this.finish = finish;
  21.     }
  22.  
  23.     // This is the method that will be used to validate data at every step
  24.     public IUIWizardStep getNextStep()
  25.     {
  26.         IUIWizardStep curstep = getVisibleStep();
  27.         switch ( callback.getID(curstep) ) {
  28.         case PVALUE:
  29.             callback.processPV();
  30.             return null;
  31.  
  32.         case NUMPERIODS:
  33.             if ( !callback.isValidNumper() )
  34.                 return curstep;
  35.             else {
  36.                 int calc = callback.getCalc();
  37.                 // do both PV and n have entered values? Yes? calculate pmnt; No? enter pmnt
  38.                 if ( (calc != BL_PV) && (calc != BL_LEN) ) {
  39.                     callback.setCalc(BL_PMNT);
  40.                     return finish; 
  41.                 }
  42.                 else
  43.                     return null;
  44.             }
  45.         case PAYMENT:
  46.             return (callback.isValidPayment() ? null : curstep);
  47.         }
  48.         return null;
  49.     }
  50.  
  51.     public void setFirstStep(WZValue firststep)
  52.     {
  53.         this.firststep = firststep;
  54.     }
  55.  
  56.     // Override getFirstStep to skip over intro
  57.     public IUIWizardStep getFirstStep()
  58.     {
  59.         if ( firststep == null )
  60.             return super.getFirstStep();
  61.         else
  62.             return (IUIWizardStep)firststep;
  63.     }
  64. }