FileDocCategorySizeDatePackage
DocFilter.javaAPI DocExample955Sat Apr 23 22:35:40 BST 2005None

DocFilter

public class DocFilter extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

		JTextField field = new JTextField(30);
		
		((AbstractDocument)(field.getDocument())).setDocumentFilter( 
			new DocumentFilter() 
		{
  			public void insertString(
				FilterBypass fb, int offset, String string, AttributeSet attr) 
					throws BadLocationException
				{
System.out.println("insert");
					fb.insertString( offset, string.toUpperCase(), attr );
				}

  			public void replace(
				FilterBypass fb, int offset, int length, String string, 
				AttributeSet attr) throws BadLocationException
				{
System.out.println("replace");
					fb.replace( offset, length, string.toUpperCase(), attr );
				}
		} );

		JFrame frame = new JFrame("User Information");
		frame.getContentPane().add( field );
		frame.pack();
		frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
		frame.setVisible(true);