01: package com.xoetrope.swing.date;
02:
03: import java.util.Date;
04:
05: import java.awt.BorderLayout;
06: import java.awt.Insets;
07: import java.awt.Point;
08:
09: import net.xoetrope.swing.XDialog;
10:
11: /**
12: * Encapsulates an instance of the XDateChooser class in a modal dialog
13: *
14: * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
15: * the GNU Public License (GPL), please see license.txt for more details. If
16: * you make commercial use of this software you must purchase a commercial
17: * license from Xoetrope.</p>
18: * <p> $Revision: 1.5 $</p>
19: */
20: public class XDateChooserDialog extends XDialog {
21: XDateChooser dateChooserCtl;
22:
23: /**
24: * Creates a new dialog
25: * @param onScreen the top left corrdiante of the new dialog.
26: */
27: public XDateChooserDialog(Point onScreen) {
28: super (true, 0);
29:
30: setLocation(onScreen);
31: setSize(200, 140);
32: contentPanel.setLayout(new BorderLayout());
33: contentPanel.add(dateChooserCtl = new XDateChooser(),
34: BorderLayout.CENTER);
35: dateChooserCtl.addNavigation(true);
36: setCaption(" Date Chooser");
37: }
38:
39: /**
40: * Gets the current date.
41: * @return the date
42: */
43: public Date getDate() {
44: return dateChooserCtl.getDate();
45: }
46:
47: /**
48: * Sets the current date.
49: * @param newDate the new date
50: */
51: public void setDate(Date newDate) {
52: dateChooserCtl.setDate(newDate);
53: }
54:
55: /**
56: * Set the styles for the date panel
57: * @param styles the styles in the following order: style, selectedStyle, weekendStyle, highlightStyle, headerStyle, threeDStyle
58: */
59: public void setStyles(String[] styles) {
60: if ((dateChooserCtl != null) && (styles.length == 6))
61: dateChooserCtl.setStyles(styles);
62: }
63:
64: /**
65: * Show or hide the day names
66: * @param state true to show the day names
67: */
68: public void setShowDayNames(boolean state) {
69: if (dateChooserCtl != null)
70: dateChooserCtl.setShowDayNames(state);
71: }
72: }
|