Revision 11849 trunk/libraries/libUI/src/org/gvsig/gui/beans/swing/cellrenderers/NumberTableCellRenderer.java
NumberTableCellRenderer.java | ||
---|---|---|
96 | 96 |
unselectedBorder = BorderFactory.createMatteBorder(2, 5, 2, |
97 | 97 |
5, table.getBackground()); |
98 | 98 |
} |
99 |
|
|
100 | 99 |
setBorder(unselectedBorder); |
101 | 100 |
} |
102 | 101 |
} |
103 | 102 |
try { |
104 |
String v; |
|
105 |
if (acceptsDoubles) { |
|
106 |
v = String.valueOf((Double) value); |
|
107 |
} else { |
|
108 |
v = String.valueOf((Integer) value); |
|
109 |
} |
|
110 | 103 |
|
111 | 104 |
JPanel content = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0)); |
112 | 105 |
content.setBackground(table.getBackground()); |
113 | 106 |
Validator valid = acceptsDoubles ? ValidatingTextField.DOUBLE_VALIDATOR : ValidatingTextField.INTEGER_VALIDATOR; |
114 |
txt = new JIncrementalNumberField(v, 6,valid, ValidatingTextField.NUMBER_CLEANER, 0, 80, 1); |
|
107 |
txt = new JIncrementalNumberField("", 6,valid, ValidatingTextField.NUMBER_CLEANER, 0, 80, 1); |
|
108 |
if (acceptsDoubles) { |
|
109 |
txt.setDouble(((Double) value).doubleValue()); |
|
110 |
} else { |
|
111 |
txt.setInteger(((Integer) value).intValue()); |
|
112 |
} |
|
113 |
|
|
115 | 114 |
txt.setBackground(table.getBackground()); |
116 | 115 |
// TODO figure out a way to know the cell's width to fit in the editor |
117 | 116 |
// txt.setPreferredSize(new Dimension( |
... | ... | |
120 | 119 |
content.add(txt); |
121 | 120 |
return content; |
122 | 121 |
} catch (ClassCastException ccEx) { |
123 |
throw new RuntimeException("Trying to use a Boolean cell renderer with a non-Boolean datatype");
|
|
122 |
throw new RuntimeException("Trying to use a numeric cell renderer with a non-numeric datatype");
|
|
124 | 123 |
} |
125 | 124 |
|
126 | 125 |
} |
Also available in: Unified diff