KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sellwin > gui > DateEditorDialog


1 package sellwin.gui;
2
3 import java.util.*;
4 import java.awt.*;
5 import java.awt.event.*;
6 import javax.swing.*;
7 import javax.swing.event.*;
8
9 // SellWin http://sourceforge.net/projects/sellwincrm
10
//Contact support@open-app.com for commercial help with SellWin
11
//This software is provided "AS IS", without a warranty of any kind.
12

13 /**
14  * This class implements the popup date-calendar
15  * dialog. It is used to edit a date value on
16  * some of the screens. It pops up when a date
17  * cell or field is clicked on by the user.
18  */

19 public class DateEditorDialog extends JDialog {
20
21
22     private DatePanel datePanel = new DatePanel();
23     private JButton okButton = new JButton("Ok");
24     private final DateEditorDialogListener myEditor;
25     
26
27     /**
28      * construct a date editor dialog
29      * @param owner the frame that owns this dialog
30      * @param editor the listener of this dialog that
31      * receives the date when this dialog hides itself
32      */

33     public DateEditorDialog(Frame owner, DateEditorDialogListener editor) {
34         super(owner, "Date Editor", true);
35
36         myEditor= editor;
37         Whiteboard wb = MainWindow.getWhiteboard();
38         setTitle(wb.getLang().getString("dateEditor"));
39         setFont(MainWindow.LABEL_FONT);
40         setSize(440, 190);
41
42         getContentPane().setLayout(new BorderLayout());
43
44         setColors();
45         setFonts();
46
47
48         okButton.addActionListener(
49           new ActionListener() {
50                 public void actionPerformed(ActionEvent e) {
51                     myEditor.setDate(datePanel.getDate());
52                     hide();
53                 }
54             });
55
56         getContentPane().add(datePanel, BorderLayout.CENTER);
57         JPanel buttonPanel = new JPanel();
58         buttonPanel.add(okButton);
59         getContentPane().add(buttonPanel, BorderLayout.SOUTH);
60
61
62         WindowListener l = new WindowAdapter() {
63             public void windowClosed(WindowEvent e) {
64             }
65
66             public void windowClosing(WindowEvent e) {
67                 hide();
68             }
69         };
70  
71         addWindowListener(l);
72
73         getRootPane().setDefaultButton(okButton);
74
75     }
76
77
78     /**
79      * set the date this dialog will display
80      * @param d the date we are setting with
81      */

82     public final void setDate(Date d) {
83         datePanel.setDate(d);
84     }
85
86     /**
87      * get the date from this dialog
88      * @return the date this dialog knows about
89      */

90     public final Date getDate() {
91         return datePanel.getDate();
92     }
93
94     /**
95      * set the dialog's colors
96      */

97     private final void setColors() {
98     }
99
100     /**
101      * set the dialog's fonts
102      */

103     private final void setFonts() {
104     }
105 }
106
Popular Tags