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

  1. //
  2. // (c) 1997 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.     public boolean appmodal = false;
  12.     private UIText pv, len, freq, intrst, pmnt;
  13.     private UIPushButton modify;
  14.     private LCCallbacks callback;
  15.     private FxColor c_static, c_dynamic, c_changed;
  16.  
  17.     public LCInfoPnl(LCParams lp, LCCallbacks lc)
  18.     {
  19.         setLayout(new UIBorderLayout());
  20.         callback = lc;
  21.  
  22.         UIGroup grp = new UIGroup("Loan Parameters");
  23.         grp.setLayout(new UIVerticalFlowLayout(UIVerticalFlowLayout.FILL, 0));
  24.  
  25.         grp.add(new ComboPnl(IDX_PV, pv = new UIText("", UIText.RIGHT), 15));
  26.         grp.add(new ComboPnl(IDX_INT, intrst = new UIText("", UIText.RIGHT), 15));
  27.         grp.add(new ComboPnl(IDX_LEN, len = new UIText("", UIText.RIGHT), 15));
  28.         grp.add(new ComboPnl(IDX_FREQ, freq = new UIText("", UIText.RIGHT), 15));
  29.         grp.add(new ComboPnl(IDX_PMNT, pmnt = new UIText("", UIText.RIGHT), 20));
  30.         grp.add(new BL(modify = new UIPushButton("Modify Parameters",
  31.                                                 UIPushButton.RAISED | UIPushButton.THICK),
  32.                                                 0,8,0,8));
  33.         c_static = new FxColor(0,0,0);
  34.         c_dynamic = new FxColor(0,0,255);
  35.         c_changed = new FxColor(255,0,0);
  36.  
  37.         intrst.setForeground(BaseColor.getColor(c_static));
  38.         freq.setForeground(BaseColor.getColor(c_static));
  39.         setParams(lp);
  40.         add(grp, "center");
  41.     }
  42.  
  43.     public void setParams(LCParams lp)
  44.     {
  45.         pv.setName("" + new DLRS(lp.pv));
  46.         len.setName("" + lp.len + " " + (lp.years ? "year(s)" : "month(s)"));
  47.         intrst.setName("" + new PRCNT(lp.i));
  48.         pmnt.setName("" + new DNC(lp.pmnt));
  49.         freq.setName(FREQ_STR[lp.hz_idx]);
  50.  
  51.         int calc = callback.getCalc();
  52.  
  53.         switch ( calc ) {
  54.         case BL_PV:
  55.             pv.setForeground(BaseColor.getColor(c_changed));
  56.             len.setForeground(BaseColor.getColor(c_dynamic));
  57.             pmnt.setForeground(BaseColor.getColor(c_dynamic));
  58.             break;
  59.         case BL_LEN:
  60.             pv.setForeground(BaseColor.getColor(c_dynamic));
  61.             len.setForeground(BaseColor.getColor(c_changed));
  62.             pmnt.setForeground(BaseColor.getColor(c_dynamic));
  63.             break;
  64.         case BL_PMNT:
  65.             pv.setForeground(BaseColor.getColor(c_dynamic));
  66.             len.setForeground(BaseColor.getColor(c_dynamic));
  67.             pmnt.setForeground(BaseColor.getColor(c_changed));
  68.             break;
  69.         }
  70.     }
  71.  
  72.     public boolean action (Event evt, Object arg)
  73.     {
  74.         if ( appmodal )
  75.             return true;
  76.  
  77.         if ( arg instanceof UIButton ) {
  78.             if ( arg == modify ) {
  79.                 WizThread wiz = new WizThread(callback, this);
  80.                 wiz.start();
  81.             }
  82.         }
  83.         return super.action(evt, arg);
  84.     }
  85.  
  86.     public Insets getInsets() { return new Insets(5, 5, 5, 10); }
  87. }
  88.  
  89. class WizThread extends Thread
  90. {
  91.     private LCCallbacks callback;
  92.     private LCInfoPnl app;
  93.  
  94.     public WizThread(LCCallbacks lc, LCInfoPnl ip)
  95.     {
  96.         callback = lc;
  97.         app = ip;
  98.     }
  99.         
  100.     public void run()
  101.     {
  102.         app.appmodal = true;
  103.         callback.invokeWizard();
  104.         app.appmodal = false;
  105.     }
  106. }
  107.  
  108. class ComboPnl extends UIPanel implements LCConsts
  109. {
  110.     private int b;
  111.  
  112.     public ComboPnl(int i, UIText data, int bottom)
  113.     {
  114.         UIGraphic grfc;
  115.         UIText label;
  116.  
  117.         b = bottom;
  118.  
  119.         grfc = new UIGraphic(LCImages.get(IDX_IMG[i]));
  120.         label = new UIText(IDX_STR[i], UIText.LEFT);
  121.  
  122.         setLayout(new UIBorderLayout());
  123.         add(grfc, "west");
  124.         UIPanel pnl = new UIPanel();
  125.         pnl.setLayout(new UIBorderLayout());
  126.         pnl.add(label, "north"); pnl.add(data, "south");
  127.         add(pnl, "center");
  128.     }
  129.  
  130.     public Insets getInsets() { return new Insets(0, 0, b, 0); }
  131. }
  132.