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

  1. //
  2. // (c) 1998 Microsoft Corporation.  All rights reserved.
  3. //
  4. import java.awt.Event;
  5. import java.awt.Insets;
  6. import com.ms.ui.*;
  7. import com.ms.fx.*;
  8.  
  9. class LCInfoPnl extends UIPanel implements LCConsts
  10. {
  11.     private UIText pv, len, freq, intrst, pmnt;
  12.     private UIPushButton modify;
  13.     private LCCallbacks callback;
  14.     private FxColor c_static, c_dynamic, c_changed;
  15.  
  16.     public LCInfoPnl(LCParams lp, LCCallbacks lc)
  17.     {
  18.         setLayout(new UIBorderLayout());
  19.         callback = lc;
  20.  
  21.         UIGroup grp = new UIGroup("Loan Parameters");
  22.         grp.setLayout(new UIVerticalFlowLayout(UIVerticalFlowLayout.FILL, 0));
  23.  
  24.         grp.add(new ComboPnl(IDX_PV, pv = new UIText("", UIText.RIGHT), 15));
  25.         grp.add(new ComboPnl(IDX_INT, intrst = new UIText("", UIText.RIGHT), 15));
  26.         grp.add(new ComboPnl(IDX_LEN, len = new UIText("", UIText.RIGHT), 15));
  27.         grp.add(new ComboPnl(IDX_FREQ, freq = new UIText("", UIText.RIGHT), 15));
  28.         grp.add(new ComboPnl(IDX_PMNT, pmnt = new UIText("", UIText.RIGHT), 20));
  29.         grp.add(new BL(modify = new UIPushButton("Modify Parameters", 
  30.                                             UIPushButton.RAISED | UIPushButton.THICK),
  31.                                             0,8,0,8));
  32.         c_static = new FxColor(0,0,0);
  33.         c_dynamic = new FxColor(0,0,255);
  34.         c_changed = new FxColor(255,0,0);
  35.  
  36.         intrst.setForeground(c_static); freq.setForeground(c_static);
  37.         setParams(lp);
  38.         add(grp, "center");
  39.     }
  40.  
  41.     public void setParams(LCParams lp)
  42.     {
  43.         pv.setName("" + new DLRS(lp.pv));
  44.         len.setName("" + lp.len + " " + (lp.years ? "year(s)" : "month(s)"));
  45.         intrst.setName("" + new PRCNT(lp.i));
  46.         pmnt.setName("" + new DNC(lp.pmnt));
  47.         freq.setName(FREQ_STR[lp.hz_idx]);
  48.  
  49.         int calc = callback.getCalc();
  50.  
  51.         switch ( calc ) {
  52.         case BL_PV:
  53.             pv.setForeground(c_changed);
  54.             len.setForeground(c_dynamic);
  55.             pmnt.setForeground(c_dynamic);
  56.             break;
  57.         case BL_LEN:
  58.             pv.setForeground(c_dynamic);
  59.             len.setForeground(c_changed);
  60.             pmnt.setForeground(c_dynamic);
  61.             break;
  62.         case BL_PMNT:
  63.             pv.setForeground(c_dynamic);
  64.             len.setForeground(c_dynamic);
  65.             pmnt.setForeground(c_changed);
  66.             break;
  67.         }
  68.     }
  69.  
  70.     public boolean action (Event evt, Object arg)
  71.     {
  72.         if ( arg instanceof UIButton ) {
  73.             if ( arg == modify )
  74.                 callback.invokeWizard();
  75.         }
  76.         return super.action(evt, arg);
  77.     }
  78.  
  79.     public Insets getInsets() { return new Insets(5, 5, 5, 10); }
  80. }
  81.  
  82. class ComboPnl extends UIPanel implements LCConsts
  83. {
  84.     private int b;
  85.  
  86.     public ComboPnl(int i, UIText data, int bottom)
  87.     {
  88.         UIGraphic grfc;
  89.         UIText label;
  90.  
  91.         b = bottom;
  92.  
  93.         grfc = new UIGraphic(LCImages.get(IDX_IMG[i]));
  94.         label = new UIText(IDX_STR[i], UIText.LEFT);
  95.  
  96.         setLayout(new UIBorderLayout());
  97.         add(grfc, "west");
  98.         UIPanel pnl = new UIPanel();
  99.         pnl.setLayout(new UIBorderLayout());
  100.         pnl.add(label, "north"); pnl.add(data, "south");
  101.         add(pnl, "center");
  102.     }
  103.  
  104.     public Insets getInsets() { return new Insets(0, 0, b, 0); }
  105. }
  106.