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

  1. //
  2. // (c) 1998 Microsoft Corporation.  All rights reserved.
  3. //
  4. import com.ms.ui.*;
  5. import com.ms.fx.*;
  6. import java.awt.Event;
  7. import java.awt.Insets;
  8.  
  9. public class WZNumPeriods extends UIWizardStep implements LCConsts
  10. {
  11.     public NumPerPnl pnl;
  12.  
  13.     public WZNumPeriods()
  14.     {
  15.         super(new UIGraphic(LCImages.get(NUMPERIODS)), new NumPerPnl());
  16.         pnl = (NumPerPnl)getContent();
  17.     }
  18. }
  19.  
  20. class NumPerPnl extends FocusUIPanel implements LCConsts
  21. {
  22.     public UIEdit len_e;
  23.     public boolean years;
  24.     public UIChoice hz_c;
  25.     public UIRadioButton btn_m, btn_y;
  26.  
  27.     public NumPerPnl()
  28.     {
  29.         setLayout(new UIBorderLayout());
  30.  
  31.         // Main text
  32.         UIDrawText dt = new UIDrawText(PERIOD_TXT);
  33.         dt.setWordWrap(IFxTextConstants.wwKeepWordIntact);
  34.  
  35.         // Create Length UIEdit
  36.         len_e = new UIEdit();
  37.         len_e.setValueText("" + INIT_LEN);
  38.         len_e.setMaxBufferSize(3); len_e.setBordered(true);
  39.         len_e.setVertAlign(IFxTextConstants.vtaCenter);
  40.         len_e.setHorizAlign(IFxTextConstants.htaCenter);
  41.         len_e.setMaskChars("0123456789"); len_e.setMaskMode(UIEdit.INCLUDE);
  42.  
  43.         // Create months/years UIGroup
  44.         UIGroup len_unit = new UIGroup();
  45.         len_unit.setLayout(new UIGridLayout(0, 1));
  46.         btn_m = new UIRadioButton("month(s)"); btn_m.setID(ID_MONTHS);
  47.         btn_y = new UIRadioButton("year(s)"); btn_y.setID(ID_YEARS);
  48.         btn_y.setChecked(true); years = true;
  49.         len_unit.add(btn_m); len_unit.add(btn_y);
  50.  
  51.         /* If months/years unit choice is done with UIRadioGroup use this code
  52.         UIRadioGroup len_unit = new UIRadioGroup();
  53.         btn_m = (UIRadioButton)len_unit.add("month(s)"); btn_m.setID(ID_MONTHS);
  54.         btn_y = (UIRadioButton)len_unit.add("year(s)"); btn_y.setID(ID_YEARS);
  55.         btn_y.setChecked(true); years = true;
  56.         */
  57.  
  58.         UIText hz_t = new UIText(FREQ_TXT, UIText.RIGHT);
  59.  
  60.         // Create frequency UIChoice
  61.         hz_c = new UIChoice();
  62.         for ( int i = 0; i < FREQ_STR.length; i++ )
  63.             hz_c.addString(FREQ_STR[i]);
  64.         hz_c.setSelectedIndex(INIT_FREQ);
  65.  
  66.         add(new HSL(new HSL(dt,
  67.                             new VSL(new BL(len_e, 0,30,1,0),
  68.                                     new BL(len_unit, 0,0,0,30),
  69.                                     115),
  70.                             38),
  71.                     new HSL(hz_t,
  72.                             new BL(hz_c, 0,0,6,0),
  73.                             32),
  74.                     82),
  75.             "center");
  76.     }
  77.  
  78.     public void setFocus() { len_e.requestFocus(); }
  79.  
  80.     public boolean action(Event e, Object arg)
  81.     {
  82.         if ( arg instanceof UIButton ) {
  83.             if ( arg == btn_m ) {
  84.                 years = false;
  85.                 btn_m.setChecked(true);
  86.                 btn_y.setChecked(false);
  87.             }
  88.             else if ( arg == btn_y ) {
  89.                 years = true;
  90.                 btn_y.setChecked(true);
  91.                 btn_m.setChecked(false);
  92.             }
  93.             setFocus();
  94.         }
  95.         return super.action(e, arg);
  96.     }    
  97.  
  98.     /* If months/years unit choice is done with UIRadioGroup use this code
  99.     public boolean handleEvent(Event e)
  100.     {
  101.         switch ( e.id ) {
  102.         case Event.LIST_SELECT:
  103.             if ( e.arg instanceof UIButton ) {
  104.                 int id = ((UIButton)e.arg).getID();
  105.  
  106.                 switch ( id ) {
  107.                 case ID_MONTHS: years = false; break;
  108.                 case ID_YEARS: years = true; break;
  109.                 }
  110.             }
  111.             setFocus();
  112.             break;
  113.         }
  114.         return(super.handleEvent(e));
  115.     }
  116.     */
  117. }
  118.  
  119.