/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package main;

/**
 *
 * @author igoriok
 */
public class FormattedTextFieldTest extends javax.swing.JFrame {


	public FormattedTextFieldTest() {
			initComponents();
	}

  private void initComponents()
  {
    formattedTextField = new javax.swing.JFormattedTextField();
    typeLabel = new javax.swing.JLabel();

    setTitle("JFormattedTextField Test");
    addWindowListener(new java.awt.event.WindowAdapter()
    {
      public void windowClosing(java.awt.event.WindowEvent evt)
      {
        exitForm(evt);
      }
    });

    formattedTextField.setColumns(20);
    formattedTextField.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
    formattedTextField.setText("  ");
    formattedTextField.setAlignmentX(0.0F);
    formattedTextField.setAlignmentY(0.0F);
    formattedTextField.setValue(new Double(1.0));
    formattedTextField.addPropertyChangeListener(new
java.beans.PropertyChangeListener()
    {
      public void propertyChange(java.beans.PropertyChangeEvent evt)
      {
        formattedTextFieldPropertyChange(evt);
      }
    });

    getContentPane().add(formattedTextField, java.awt.BorderLayout.NORTH);

    typeLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    typeLabel.setText("java.lang.Double");
    getContentPane().add(typeLabel, java.awt.BorderLayout.CENTER);

    pack();
  }

  private void formattedTextFieldPropertyChange(java.beans.PropertyChangeEvent
evt)
  {
    if (evt.getPropertyName() == "value" && evt.getNewValue() != null)
      typeLabel.setText(evt.getNewValue().getClass().toString());
  }

    /** Exit the Application */
    private void exitForm(java.awt.event.WindowEvent evt) {
        System.exit(0);
    }

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
      new FormattedTextFieldTest().show();
    }


  private javax.swing.JLabel typeLabel;
  private javax.swing.JFormattedTextField formattedTextField;

}