Skip to main content

[patch] make JXTable.DateRenderer more useful

No replies
Anonymous

Hi

I needed to render some dates, and this class was right there!! Just
needed a little tweaking.

Index: JXTable.java
===================================================================
RCS file: /cvs/swingx/src/java/org/jdesktop/swingx/JXTable.java,v
retrieving revision 1.55
diff -u -r1.55 JXTable.java
--- JXTable.java 29 Jul 2005 09:01:13 -0000 1.55
+++ JXTable.java 5 Aug 2005 07:21:44 -0000
@@ -1851,16 +1851,21 @@
}

public static class DateRenderer extends DefaultTableCellRenderer {
- DateFormat formatter;
+ private final DateFormat formatter;

+ public DateRenderer(DateFormat formatter) {
+ if (formatter == null) {
+ this.formatter = DateFormat.getDateInstance();
+ } else {
+ this.formatter = formatter;
+ }
+ }
+
public DateRenderer() {
- super();
+ this(null);
}

public void setValue(Object value) {
- if (formatter == null) {
- formatter = DateFormat.getDateInstance();
- }
setText((value == null) ? "" : formatter.format(value));
}
}

NOTICE: Please note that this email, and the contents thereof,
are subject to the standard Peralex email disclaimer, which may
be found at: http://www.peralex.com/disclaimer.html

If you cannot access the disclaimer through the URL attached
and you wish to receive a copy thereof please send
an email to email@peralex.com

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net