01: package jimm.datavision.gui.parameter;
02:
03: import jimm.datavision.Parameter;
04: import java.util.Date;
05: import java.util.Calendar;
06: import javax.swing.*;
07: import com.toedter.calendar.JCalendar;
08:
09: /**
10: * A single date inquisitor knows how to display and control the widgets
11: * needed to ask a user for a date parameter value.
12: *
13: * @author Jim Menard, <a href="mailto:jimm@io.com">jimm@io.com</a>
14: */
15: class SingleDateInq extends Inquisitor {
16:
17: protected JCalendar cal;
18:
19: SingleDateInq(Parameter param) {
20: super (param);
21:
22: // Build GUI. Use current date as default value.
23: JPanel innerPanel = new JPanel();
24: innerPanel.add(cal = new JCalendar());
25: panel.add(innerPanel);
26:
27: // Copy default value into "real" value. Default value is the
28: // current date and time.
29: parameter.setValue(0, parameter.getDefaultValue(0));
30: }
31:
32: void copyGUIIntoParam() {
33: parameter.setValue(0, cal.getCalendar().getTime());
34: }
35:
36: void copyParamIntoGUI() {
37: Calendar calendar = Calendar.getInstance();
38: calendar.setTime((Date) parameter.getValue(0));
39: cal.setCalendar(calendar);
40: }
41:
42: }
|