1 package sellwin.gui; 2 3 import sellwin.utils.*; 4 5 import java.awt.*; 6 import java.util.*; 7 import javax.swing.*; 8 import javax.swing.event.*; 9 import javax.swing.table.*; 10 11 15 20 public class DateTimeRenderer extends JLabel implements TableCellRenderer { 21 22 private Date currentDate; 23 24 27 public DateTimeRenderer() { 28 super(); 29 setBackground(MainWindow.LETTERS); 30 setFont(MainWindow.FIELD_FONT); 31 } 32 33 44 public final Component getTableCellRendererComponent( 45 JTable table, Object date, 46 boolean isSelected, boolean hasFocus, 47 int row, int col) { 48 49 currentDate = (Date)date; 50 51 if (date == null) 52 date = new Date(); 53 setText(Prefs.dateTimeFormat.format((Date)date)); 54 return this; 55 } 56 57 58 62 public final Date getDate() { 63 return currentDate; 64 } 65 66 70 public final void setValue(Object value) { 71 if (value == null) 72 currentDate = new Date(); 73 else { 74 currentDate = (Date)value; 75 } 76 77 setText(Prefs.dateTimeFormat.format((Date)currentDate)); 78 } 79 } 80 | Popular Tags |