IntegerField.java revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* ident "%Z%%M% %I% %E% SMI"
*
* Copyright (c) 1998-1999 by Sun Microsystems, Inc.
* All rights reserved.
*/
/**
* A text field which limits input to only digits.
*/
public class IntegerField extends JTextField {
/**
* Construct an empty field
*/
public IntegerField() {
this("");
}
/**
* Construct a field initialized to the specified text. Defaults to a width
* of 5 characters.
* @param text The initial text to display
*/
this(text, 5);
}
/**
* Construct a field initialized to the specified value. Defaults to a
* width of 5 characters.
* @param value The initial value to display
*/
public IntegerField(int value) {
this();
}
/**
* Construct a field initialized to the specified Integer object.
* Defaults to a width of 5 characters.
* @param value The initial value to display
*/
this();
}
/**
* Construct a field initialized to the specified text and width.
* @param text The initial text to display
* @param width The width of the field in characters
*/
}
/**
* Set the value of the field
* @param value An <code>int</code> value to set
*/
}
/**
* Set the value of the field
* @param value The value to set as an <code>Integer</code>
*/
}
}
/**
* Retrieve the entered value
* @return The value stored in the field as an <code>int</code>
*/
public int getValue() {
return 0;
} else {
}
}
protected Document createDefaultModel() {
return new IntegerDocument();
}
/*
* This is the recommended way to validate input, as opposed to trapping
* KeyEvents because this will actually catch paste operations as well.
*/
static class IntegerDocument extends PlainDocument {
throws BadLocationException {
}
}
}
}
}
}