

/****
	* Classe DDocumentNumber : permet de personnaliser la gestion du "model" des composants Texte
	*        proposee dans l'api de swing 
	*
	****/


import javax.swing.text.*;
import java.text.*;
import javax.swing.*;
import java.awt.BorderLayout;

public class TestDocumentNumber1 extends JFrame
{
	public TestDocumentNumber1 ()
	{
		super ("Demo");

		NumberFormat nf = NumberFormat.getNumberInstance ();
		nf.setParseIntegerOnly (true);

		JFormattedTextField texte = new JFormattedTextField (nf);
		// pour vérifie la saisie à la volée (sinon c'est à la perte de focus)
		((DefaultFormatter) texte.getFormatter ()).setAllowsInvalid (false);


		this.getContentPane ().add (texte);
		this.getContentPane ().add (new JButton ("decoration"), BorderLayout.SOUTH);

		this.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
		this.setLocation (200, 200);
		this.pack ();
		this.setVisible (true);
	}

	public static void main (String argv [])
	{
		new TestDocumentNumber1 ();
	}
}
