public void setFormat(String format) {
		String contents = getText().trim();
		int value = 0;
		if (contents.length() != 0) {
			try {
				value = parser.parse(contents).intValue();
			} catch (ParseException ex) {
				throw new ErrorException(ex);
			}
		}
		formatString = format;
		if (format == null) {
			formatter = null;
			parser = NumberFormat.getNumberInstance(Locale.US);
		} else {
			formatter = (format.length() == 0) ? new DecimalFormat() : new DecimalFormat(format);
			parser = formatter;
		}
		if (contents.length() != 0) {
			setValue(value);
		}
	}