00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 package ikayaki.gui;
00024
00025 import java.text.DecimalFormat;
00026 import java.text.FieldPosition;
00027 import java.text.ParseException;
00028
00034 public class PositiveDecimalFormat extends DecimalFormat {
00035
00036 @Override public StringBuffer format(double number, StringBuffer result, FieldPosition fieldPosition) {
00037 if (number < 0.0) {
00038 return result;
00039 }
00040 return super.format(number, result, fieldPosition);
00041 }
00042
00043 @Override public StringBuffer format(long number, StringBuffer result, FieldPosition fieldPosition) {
00044 if (number < 0) {
00045 return result;
00046 }
00047 return super.format(number, result, fieldPosition);
00048 }
00049
00050 @Override public Object parseObject(String source) throws ParseException {
00051 if (source.equals("")) {
00052 return new Long(-1);
00053 }
00054 return super.parseObject(source);
00055 }
00056 }