How can i set a minimum date for the JXDatePicker in my JTable column.That is i need to show/enable only the date greater than current date in the JXDatePicker,date below current date should be desabled in the calender so that user can't select those dates.How to do that?Please help me.Below is my code.
import java.util.Date;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.table.TableColumn;
import org.jdesktop.swingx.table.DatePickerCellEditor;
public class TableWithDate {
private static void createAndShowGUI() {
JFrame frame = new JFrame("TableWithDate");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JTable table = new JTable(new Object[][] { { "1", new Date() } },
new Object[] { "Id", "Time" });
TableColumn dateColumn = table.getColumnModel().getColumn(1);
dateColumn.setCellEditor(new DatePickerCellEditor());
JScrollPane scrollPane = new JScrollPane(table);
frame.add(scrollPane);
frame.pack();
frame.setVisible(true);
}
public static void main(String args[]) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}
The
JXDatePicker
field hasprotected
access, you'll have to extendDatePickerCellEditor
and provide that functionality...Runnable example...
If you want to disclude today as well, you could use something like...
...for example