package com.han;
import javax.swing.JTextField;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.PlainDocument;
/**
* Customized fields can easily be created by extending the model
* and changing the default model provided. For example,
* the following piece of code will create a field that holds only
* digit characters. It will work even if text is pasted into from
* the clipboard or it is altered via programmatic changes.
* @author HAN
*
*/
public class DigitOnlyField extends JTextField {
/**
*
*/
private static final long serialVersionUID = 8384787369612949227L;
public DigitOnlyField(int cols) {
// super() 可以被自动调用,但是有参构造方法并不能被自动调用,只能依