Save This Page
Home » openjdk-7 » net.bereza.money » gui » [javadoc | source]
    1   /*
    2    *  Copyright (C) 2000  Bill Bereza
    3    *
    4    *  This program is free software; you can redistribute it and/or modify
    5    *  it under the terms of the GNU General Public License as published by
    6    *  the Free Software Foundation; either version 2 of the License, or
    7    *  (at your option) any later version.
    8    *
    9    *  This program is distributed in the hope that it will be useful,
   10    *  but WITHOUT ANY WARRANTY; without even the implied warranty of
   11    *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   12    *  GNU General Public License for more details.
   13    *
   14    *  You should have received a copy of the GNU General Public License
   15    *  along with this program; if not, write to the Free Software
   16    *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   17    *
   18    *  Author: Bill Bereza
   19    *  email : bereza@pobox.com
   20    *  url   : http://www.pobox.com/~bereza/
   21    */
   22   package net.bereza.money.gui;
   23   
   24   import net.bereza.money.db;
   25   
   26   import java.io;
   27   import java.util;
   28   import java.math.BigDecimal;
   29   import java.text.MessageFormat;
   30   
   31   import java.awt;
   32   import java.awt.event;
   33   import javax.swing;
   34   import javax.swing.event;
   35   import javax.swing.text;
   36   
   37   /**
   38    * KDollarsPanel is a sub-class of DollarsPanel that works with
   39    * the Kiwi NumericField.
   40    *
   41    * @author $Author: bereza $
   42    * @version $Revision: 1.3 $
   43    * <p>
   44    * $Log: KDollarsPanel.java,v $
   45    * Revision 1.3  2000/03/30 01:57:34  bereza
   46    * Added copyright header
   47    *
   48    * Revision 1.2  2000/03/29 02:03:28  bereza
   49    * package name changes
   50    *
   51    * Revision 1.1  1999/09/06 16:34:04  bereza
   52    * Initial revision
   53    *
   54    * <p>
   55    * 	$Id: KDollarsPanel.java,v 1.3 2000/03/30 01:57:34 bereza Exp $
   56    */
   57   public class KDollarsPanel extends DollarsPanel
   58   {
   59     /** numeric field we work with */
   60     private kiwi.ui.NumericField numberField;
   61     
   62     public KDollarsPanel(kiwi.ui.NumericField field)
   63     {
   64       super();
   65   
   66       numberField=field;
   67   
   68       numberField.getDocument().addDocumentListener(this);
   69     }
   70   
   71     /**
   72      * Get the numeric text from the document, convert it to a written
   73      * representation, and display it in the writtenLabel.
   74      * @param d Document to display
   75      * @exception NumberFormatException if the document is not a number string
   76      */
   77     public synchronized void displayDocument(Document d)
   78     {
   79       //if(numberField.checkInput())
   80       //{
   81         writtenLabel.setText(getWrittenString(
   82           new BigDecimal(numberField.getValue()).toString()));
   83         //}
   84     }
   85   
   86     public static void main(String argv[])
   87     {
   88       JFrame tFrame=new JFrame("DollarsPanel test");
   89       kiwi.ui.NumericField tField=
   90         new kiwi.ui.NumericField(10,
   91                                  kiwi.text.FormatConstants.CURRENCY_FORMAT);
   92       KDollarsPanel dp=new KDollarsPanel(tField);
   93   
   94       tFrame.getContentPane().setLayout(new BorderLayout());
   95   
   96       tFrame.getContentPane().add("North",tField);
   97       
   98       tFrame.getContentPane().add("Center",dp);
   99       
  100       tFrame.addWindowListener(new WindowAdapter()
  101                                {
  102                                  public void windowClosing(WindowEvent e)
  103                                    {
  104                                      System.exit(0);
  105                                    }
  106                                });
  107       
  108       
  109                                
  110       tFrame.pack();
  111       tFrame.show(); 
  112     } 
  113   }
  114   

Save This Page
Home » openjdk-7 » net.bereza.money » gui » [javadoc | source]