01: package org.jsqltool.gui.graphics;
02:
03: import java.awt.*;
04: import java.text.*;
05: import java.util.*;
06:
07: import javax.swing.*;
08: import javax.swing.event.*;
09: import javax.swing.table.*;
10: import org.jsqltool.utils.Options;
11:
12: /**
13: * <p>Title: JSqlTool Project</p>
14: * <p>Description: Renderer for date cell: it shows a formatted date.
15: * </p>
16: * <p>Copyright: Copyright (C) 2006 Mauro Carniel</p>
17: *
18: * <p> This file is part of JSqlTool project.
19: * This library is free software; you can redistribute it and/or
20: * modify it under the terms of the (LGPL) Lesser General Public
21: * License as published by the Free Software Foundation;
22: *
23: * GNU LESSER GENERAL PUBLIC LICENSE
24: * Version 2.1, February 1999
25: *
26: * This library is distributed in the hope that it will be useful,
27: * but WITHOUT ANY WARRANTY; without even the implied warranty of
28: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29: * Library General Public License for more details.
30: *
31: * You should have received a copy of the GNU Library General Public
32: * License along with this library; if not, write to the Free
33: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
34: *
35: * The author may be contacted at:
36: * maurocarniel@tin.it</p>
37: *
38: * @author Mauro Carniel
39: * @version 1.0
40: */
41: public class DateCellRenderer extends DefaultTableCellRenderer {
42:
43: /** date formatted */
44: protected SimpleDateFormat dateFormat = new SimpleDateFormat(
45: Options.getInstance().getDateFormat());
46:
47: public DateCellRenderer() {
48: }
49:
50: public Component getTableCellRendererComponent(JTable table,
51: Object value, boolean isSelected, boolean hasFocus,
52: int row, int column) {
53: JLabel tf = (JLabel) super .getTableCellRendererComponent(table,
54: value, isSelected, hasFocus, row, column);
55: if (value == null)
56: tf.setText("");
57: else
58: tf.setText(dateFormat.format((Date) value));
59:
60: return tf;
61: }
62:
63: }
|