01: package com.xoetrope.swing.table;
02:
03: import java.text.Format;
04:
05: /**
06: * A cell renderer for a formatted field e.g. a decimal format
07: *
08: * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
09: * the GNU Public License (GPL), please see license.txt for more details. If
10: * you make commercial use of this software you must purchase a commercial
11: * license from Xoetrope.</p>
12: * <p> $Revision: 1.6 $</p>
13: */
14: public class XFormattedTableCellRenderer extends
15: XAltRowTableCellRenderer {
16: protected Format format;
17:
18: /**
19: * Creates a default table cell renderer.
20: */
21: public XFormattedTableCellRenderer(Format cellFormat) {
22: super ();
23: format = cellFormat;
24: }
25:
26: /**
27: * Sets the <code>String</code> object for the cell being rendered to
28: * <code>value</code>.
29: *
30: * @param value the string value for this cell; if value is
31: * <code>null</code> it sets the text value to an empty string
32: * @see JLabel#setText
33: *
34: */
35: public void setValue(Object value) {
36: setText((value == null) ? "" : format.format(new Double(value
37: .toString())));
38: }
39: }
|