zsh_root
2024-01-02 7b595546af704983dbafcd0d385c8768ddacefc2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
package PbuliClass;
import java.awt.BorderLayout;  
import java.awt.Color;  
import java.awt.Cursor;  
import java.awt.Dimension;  
import java.awt.FlowLayout;  
import java.awt.Font;  
import java.awt.Frame;  
import java.awt.GridLayout;  
import java.awt.Point;   
import java.awt.event.ActionEvent;  
import java.awt.event.ActionListener;  
import java.text.ParseException;  
import java.text.SimpleDateFormat;  
import java.util.Calendar;  
import java.util.Date;    
import javax.swing.JButton;  
import javax.swing.JDialog; 
import javax.swing.JLabel;  
import javax.swing.JPanel;  
import javax.swing.JSpinner;  
import javax.swing.SpinnerNumberModel;  
import javax.swing.SwingConstants;  
import javax.swing.SwingUtilities;  
import javax.swing.border.LineBorder;  
import javax.swing.event.ChangeEvent;  
import javax.swing.event.ChangeListener;
 
import Frame.TrackPlay;
  
/** 
 * ¸ÃÀàÓÃÓÚÑ¡Ôñʱ·ÖÃë
 * YouAreStupid ÊÕ¼¯ÍøÉÏ¿¿Æ×µÄÀý×Ó£¬Ð޸ĺóµÄSwingÈÕÆÚ 
 * Ê±¼äÑ¡ÔñÆ÷,ÒòΪÐÞ¸Äʱ¼ä´Ò棬ϣÍûÓÐʱ¼äµÄÅóÓѼÌÐø¸Ä½ø¡£ 
 * Àý×ÓÔ­×÷Õß:ZJW 
 * ÐÞ¸Ä/ÍêÉÆ£ºYouAreStupid  
 */  
public class GetDate extends JButton {  
  
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    
    private DateChooser dateChooser = null;  
    private String preLabel = "";  
    private String originalText = null;  
    private SimpleDateFormat sdf = null;  
  
    public GetDate() {        
        this(getNowDate());  
        Font f=new Font("΢ÈíÑźÚ",Font.PLAIN,15);//°´Å¥×ÖÌåÉèÖÃ
        this.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));//Êó±êÖ¸ÔÚ°´Å¥ÉϱäÊÖÐÍ
        this.setFont(f);    
        this.setForeground(Color.black);
        this.setBackground(Color.white);
    }  
  
    public GetDate(String dateString) {  
        this();  
        setText(getDefaultDateFormat(), dateString);  
        //±£´æÔ­Ê¼µÄÈÕÆÚʱ¼ä  
        initOriginalText(dateString);  
    }  
  
    public GetDate(SimpleDateFormat df, String dateString) {  
        this();  
        setText(df, dateString);  
  
        //¼ÇÒ䵱ǰµÄÈÕÆÚ¸ñʽ»¯Æ÷  
        this.sdf = df;  
  
        //¼ÇÒäԭʼÈÕÆÚʱ¼ä  
        Date originalDate = null;  
        try {  
            originalDate = df.parse(dateString);  
        } catch (ParseException ex) {  
            originalDate = getNowDate();  
        }  
        initOriginalText(originalDate);  
    }  
  
    public GetDate(Date date) {  
        this("", date);  
        //¼ÇÒäԭʼÈÕÆÚʱ¼ä  
        initOriginalText(date);  
    }  
  
    public GetDate(String preLabel, Date date) {  
        if (preLabel != null) {  
            this.preLabel = preLabel;  
        }  
        setDate(date);  
        //¼ÇÒäԭʼÊÇÈÕÆÚʱ¼ä  
        initOriginalText(date);  
  
        setBorder(null);  
        setCursor(new Cursor(Cursor.HAND_CURSOR));  
        super.addActionListener(new ActionListener() {  
  
            @Override  
            public void actionPerformed(ActionEvent e) {  
                if (dateChooser == null) {  
                    dateChooser = new DateChooser();  
                }  
                Point p = getLocationOnScreen();  
                p.y = p.y + 30;  
                dateChooser.showDateChooser(p);  
            }  
        });  
    }  
  
    private static Date getNowDate() {  
        return Calendar.getInstance().getTime();  
    }  
  
    private static SimpleDateFormat getDefaultDateFormat() {  
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
    }  
  
    /** 
     * µÃµ½µ±Ç°Ê¹ÓõÄÈÕÆÚ¸ñʽ»¯Æ÷ 
     * @return ÈÕÆÚ¸ñʽ»¯Æ÷ 
     */  
    public SimpleDateFormat getCurrentSimpleDateFormat(){  
        if(this.sdf != null){  
            return sdf;  
        }else{  
            return getDefaultDateFormat();  
        }  
    }  
  
  
    //±£´æÔ­Ê¼ÊÇÈÕÆÚʱ¼ä  
    private void initOriginalText(String dateString) {  
        this.originalText = dateString;  
    }  
  
    //±£´æÔ­Ê¼ÊÇÈÕÆÚʱ¼ä  
    private void initOriginalText(Date date) {  
        this.originalText = preLabel + getDefaultDateFormat().format(date);  
    }  
  
    /**  
     * µÃµ½µ±Ç°¼ÇÒäµÄԭʼÈÕÆÚʱ¼ä 
     * @return µ±Ç°¼ÇÒäµÄԭʼÈÕÆÚʱ¼ä£¨Î´ÐÞ¸ÄǰµÄÈÕÆÚʱ¼ä£© 
     */  
    public String getOriginalText() {  
        return originalText;  
    }  
  
    // ¸²¸Ç¸¸ÀàµÄ·½·¨  
    @Override  
    public void setText(String s) {  
        Date date;  
        try {  
            date = getDefaultDateFormat().parse(s);  
        } catch (ParseException e) {  
            date = getNowDate();  
        }  
        setDate(date);  
    }  
  
    public void setText(SimpleDateFormat df, String s) {  
        Date date;  
        try {  
            date = df.parse(s);  
        } catch (ParseException e) {  
            date = getNowDate();  
        }  
        setDate(date);  
    }  
  
    public void setDate(Date date) {  
        super.setText(preLabel + getDefaultDateFormat().format(date));  
    }  
  
    public Date getDate() {  
        String dateString = getText().substring(preLabel.length());  
        try {  
            SimpleDateFormat currentSdf = getCurrentSimpleDateFormat();  
            return currentSdf.parse(dateString);  
        } catch (ParseException e) {  
            return getNowDate();  
        }  
    }  
  
    /**   
     * ¸²¸Ç¸¸ÀàµÄ·½·¨Ê¹Ö®ÎÞЧ 
     * @param listener ÏìÓ¦¼àÌýÆ÷ 
     */  
    @Override  
    public void addActionListener(ActionListener listener) {  
    }  
  
    /** 
     * ÄÚ²¿À࣬Ö÷ÒªÊǶ¨ÒåÒ»¸öJPanel£¬È»ºó°ÑÈÕÀúÏà¹ØµÄËùÓÐÄÚÈÝÌîÈë±¾JPanel£¬ 
     * È»ºóÔÙ´´½¨Ò»¸öJDialog£¬°Ñ±¾ÄÚ²¿ÀඨÒåµÄJPanel·ÅÈëJDialogµÄÄÚÈÝÇø 
     */  
    @SuppressWarnings("serial")
    
    private class DateChooser extends JPanel implements ActionListener, ChangeListener {  
  
        int startYear = 1980; // Ä¬ÈÏ¡¾×îС¡¿ÏÔʾÄê·Ý  
        int lastYear = 2050; // Ä¬ÈÏ¡¾×î´ó¡¿ÏÔʾÄê·Ý  
        int width = 390; // ½çÃæ¿í¶È  
        int height = 300; // ½çÃæ¸ß¶È  
        Color backGroundColor = Color.gray; // µ×É«  
        // ÔÂÀú±í¸ñÅäÉ«----------------//  
        Color palletTableColor = Color.white; // ÈÕÀú±íµ×É«  
        Color todayBackColor = Color.orange; // ½ñÌì±³¾°É«  
        Color weekFontColor = Color.blue; // ÐÇÆÚÎÄ×ÖÉ«  
        Color dateFontColor = Color.black; // ÈÕÆÚÎÄ×ÖÉ«  
        Color weekendFontColor = Color.red; // ÖÜÄ©ÎÄ×ÖÉ«  
        // ¿ØÖÆÌõÅäÉ«------------------//  
        Color controlLineColor = Color.pink; // ¿ØÖÆÌõµ×É«  
        Color controlTextColor = Color.white; // ¿ØÖÆÌõ±êÇ©ÎÄ×ÖÉ«  
        @SuppressWarnings("unused")
        Color rbFontColor = Color.white; // RoundBoxÎÄ×ÖÉ«  
        @SuppressWarnings("unused")
        Color rbBorderColor = Color.red; // RoundBox±ß¿òÉ«  
        @SuppressWarnings("unused")
        Color rbButtonColor = Color.pink; // RoundBox°´Å¥É«         
        @SuppressWarnings("unused")
        Color rbBtFontColor = Color.red; // RoundBox°´Å¥ÎÄ×ÖÉ«  
        /** µã»÷DateChooserButtonʱµ¯³öµÄ¶Ô»°¿ò£¬ÈÕÀúÄÚÈÝÔÚÕâ¸ö¶Ô»°¿òÄÚ */  
        JDialog dialog;  
        JSpinner yearSpin;  
        JSpinner monthSpin;  
        JSpinner daySpin;  
        JSpinner hourSpin;  
        JSpinner minuteSpin;  
        JSpinner secondSpin;  
        JButton[][] daysButton = new JButton[6][7];  
  
        DateChooser() {  
  
            setLayout(new BorderLayout());  
            setBorder(new LineBorder(backGroundColor, 2));  
            setBackground(backGroundColor);  
  
            JPanel topYearAndMonth = createYearAndMonthPanal();  
            add(topYearAndMonth, BorderLayout.NORTH);  
            JPanel centerWeekAndDay = createWeekAndDayPanal();  
            add(centerWeekAndDay, BorderLayout.CENTER);  
            JPanel buttonBarPanel = createButtonBarPanel();  
            this.add(buttonBarPanel, BorderLayout.SOUTH);
        }  
  
        private JPanel createYearAndMonthPanal() {  
            Calendar c = getCalendar();  
            int currentYear = c.get(Calendar.YEAR);  
            int currentMonth = c.get(Calendar.MONTH) + 1;  
            int currentHour = c.get(Calendar.HOUR_OF_DAY);  
            int currentMinute = c.get(Calendar.MINUTE);  
            int currentSecond = c.get(Calendar.SECOND);  
  
            JPanel result = new JPanel();  
            result.setLayout(new FlowLayout());  
            result.setBackground(controlLineColor);  
  
            yearSpin = new JSpinner(new SpinnerNumberModel(currentYear, startYear, lastYear, 1));  
            yearSpin.setPreferredSize(new Dimension(48, 20));  
            yearSpin.setName("Year");  
            yearSpin.setEditor(new JSpinner.NumberEditor(yearSpin, "####"));  
            yearSpin.addChangeListener(this);  
            result.add(yearSpin);  
  
            JLabel yearLabel = new JLabel("Äê");  
            yearLabel.setForeground(controlTextColor);  
            result.add(yearLabel);  
  
            monthSpin = new JSpinner(new SpinnerNumberModel(currentMonth, 1, 12, 1));  
            monthSpin.setPreferredSize(new Dimension(35, 20));  
            monthSpin.setName("Month");  
            monthSpin.addChangeListener(this);  
            result.add(monthSpin);  
  
            JLabel monthLabel = new JLabel("ÔÂ");  
            monthLabel.setForeground(controlTextColor);  
            result.add(monthLabel);  
  
            //Èç¹ûÕâÀïÒªÄܹ»Ñ¡Ôñ,»áÒªÅжϺܶණÎ÷,±ÈÈçÿ¸öÔ·ֱðÓɶàÉÙÈÕ,ÒÔ¼°ÈòÄêÎÊÌâ.ËùÒÔ,¾Í¸É´à°ÑEnableÉèΪfalse  
            daySpin = new JSpinner(new SpinnerNumberModel(currentMonth, 1, 31, 1));  
            daySpin.setPreferredSize(new Dimension(35, 20));  
            daySpin.setName("Day");  
            daySpin.addChangeListener(this);  
            daySpin.setEnabled(false);  
            daySpin.setToolTipText("ÇëÏÂÏÂÃæµÄÈÕÀúÃæ°åÖнøÐÐÑ¡ÔñÄÄÒ»Ì죡");  
            result.add(daySpin);  
  
            JLabel dayLabel = new JLabel("ÈÕ");  
            dayLabel.setForeground(controlTextColor);  
            result.add(dayLabel);  
  
            hourSpin = new JSpinner(new SpinnerNumberModel(currentHour, 0, 23, 1));  
            hourSpin.setPreferredSize(new Dimension(35, 20));  
            hourSpin.setName("Hour");  
            hourSpin.addChangeListener(this);  
            result.add(hourSpin);  
  
            JLabel hourLabel = new JLabel("ʱ");  
            hourLabel.setForeground(controlTextColor);  
            result.add(hourLabel);  
  
            minuteSpin = new JSpinner(new SpinnerNumberModel(currentMinute, 0, 59, 1));  
            minuteSpin.setPreferredSize(new Dimension(35, 20));  
            minuteSpin.setName("Minute");  
            minuteSpin.addChangeListener(this);  
            result.add(minuteSpin);  
  
            JLabel minuteLabel = new JLabel("·Ö");  
            hourLabel.setForeground(controlTextColor);  
            result.add(minuteLabel);  
  
            secondSpin = new JSpinner(new SpinnerNumberModel(currentSecond, 0, 59, 1));  
            secondSpin.setPreferredSize(new Dimension(35, 20));  
            secondSpin.setName("Second");  
            secondSpin.addChangeListener(this);  
            result.add(secondSpin);  
  
            JLabel secondLabel = new JLabel("Ãë");  
            hourLabel.setForeground(controlTextColor);  
            result.add(secondLabel);  
  
            return result;  
        }  
  
        private JPanel createWeekAndDayPanal() {  
            String colname[] = {"ÈÕ", "Ò»", "¶þ", "Èý", "ËÄ", "Îå", "Áù"};  
            JPanel result = new JPanel();  
            // ÉèÖù̶¨×ÖÌ壬ÒÔÃâµ÷Óû·¾³¸Ä±äÓ°Ïì½çÃæÃÀ¹Û  
            result.setFont(new Font("ËÎÌå", Font.PLAIN, 12));  
            result.setLayout(new GridLayout(7,7));  
            result.setBackground(Color.white);  
            JLabel cell;  
  
            for (int i = 0; i < 7; i++) {  
                cell = new JLabel(colname[i]);  
                cell.setHorizontalAlignment(JLabel.CENTER);  
                if (i == 0 || i == 6) {  
                    cell.setForeground(weekendFontColor);  
                } else {  
                    cell.setForeground(weekFontColor);  
                }  
                result.add(cell);  
            }  
  
            int actionCommandId = 0;  
            for (int i = 0; i < 6; i++) {  
                for (int j = 0; j < 7; j++) {  
                    JButton numberButton = new JButton();  
                    numberButton.setBorder(null);  
                    numberButton.setHorizontalAlignment(SwingConstants.CENTER);  
                    numberButton.setActionCommand(String.valueOf(actionCommandId));  
                    numberButton.addActionListener(this);  
                    numberButton.setBackground(palletTableColor);  
                    numberButton.setForeground(dateFontColor);  
                    if (j == 0 || j == 6) {  
                        numberButton.setForeground(weekendFontColor);  
                    } else {  
                        numberButton.setForeground(dateFontColor);  
                    }  
                    daysButton[i][j] = numberButton;  
                    result.add(numberButton);  
                    actionCommandId++;  
                }  
            }  
  
            return result;  
        }  
  
        /** µÃµ½DateChooserButtonµÄµ±Ç°text£¬±¾·½·¨ÊÇΪ°´Å¥Ê¼þÄäÃûÀà×¼±¸µÄ¡£ */  
        public String getTextOfDateChooserButton() {  
            return getText();  
        }  
  
        /** »Ö¸´DateChooserButtonµÄԭʼÈÕÆÚʱ¼ätext£¬±¾·½·¨ÊÇΪ°´Å¥Ê¼þÄäÃûÀà×¼±¸µÄ¡£ */  
        public void restoreTheOriginalDate() {  
            String originalText = getOriginalText();  
            setText(originalText);  
        }  
  
        private JPanel createButtonBarPanel() {  
            JPanel panel = new JPanel();  
            panel.setLayout(new GridLayout(1, 2));
  
            JButton ok = new JButton("È·¶¨");  
            ok.setBackground(Color.white);
            ok.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));//Êó±êÖ¸ÔÚ°´Å¥ÉϱäÊÖÐÍ
            ok.addActionListener(new ActionListener() {  
  
                @Override  
                public void actionPerformed(ActionEvent e) {  
                    //¼ÇÒäԭʼÈÕÆÚʱ¼ä  
                    initOriginalText(getTextOfDateChooserButton());  
                    //Òþ²ØÈÕÀú¶Ô»°¿ò  
                    TrackPlay.setFalstchoose(0);
                    dialog.setVisible(false);  
                }  
            });  
            panel.add(ok);  
  
            JButton cancel = new JButton("È¡Ïû");  
            cancel.setBackground(Color.white);
            cancel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));//Êó±êÖ¸ÔÚ°´Å¥ÉϱäÊÖÐÍ
            cancel.addActionListener(new ActionListener() {  
  
                @Override  
                public void actionPerformed(ActionEvent e) {  
                    //»Ö¸´Ô­Ê¼µÄÈÕÆÚʱ¼ä  
                    restoreTheOriginalDate();  
                    //Òþ²ØÈÕÀú¶Ô»°¿ò  
                    dialog.setVisible(false);  
                }  
            });  
  
            panel.add(cancel);  
            return panel;  
        }  
  
        private JDialog createDialog(Frame owner) {  
            JDialog result = new JDialog(owner, "ÈÕÆÚʱ¼äÑ¡Ôñ", true);  
            result.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);  
            result.getContentPane().add(this, BorderLayout.CENTER);  
            result.pack();  
            result.setSize(width, height);  
            return result;  
        }  
  
        void showDateChooser(Point position) {  
            Frame owner = (Frame) SwingUtilities.getWindowAncestor(GetDate.this);  
            if (dialog == null || dialog.getOwner() != owner) {  
                dialog = createDialog(owner);  
            }  
            dialog.setLocation(getAppropriateLocation(owner, position));  
            flushWeekAndDay();  
            dialog.setVisible(true);  
        }  
  
        Point getAppropriateLocation(Frame owner, Point position) {  
            Point result = new Point(position);  
            Point p = owner.getLocation();  
            int offsetX = (position.x + width) - (p.x + owner.getWidth());  
            int offsetY = (position.y + height) - (p.y + owner.getHeight());  
  
            if (offsetX > 0) {  
                result.x -= offsetX;  
            }  
  
            if (offsetY > 0) {  
                result.y -= offsetY;  
            }  
  
            return result;  
        }  
  
        private Calendar getCalendar() {  
            Calendar result = Calendar.getInstance();  
            result.setTime(getDate());  
            return result;  
        }  
  
        private int getSelectedYear() {  
            return ((Integer) yearSpin.getValue()).intValue();  
        }  
  
        private int getSelectedMonth() {  
            return ((Integer) monthSpin.getValue()).intValue();  
        }  
  
        private int getSelectedHour() {  
            return ((Integer) hourSpin.getValue()).intValue();  
        }  
  
        private int getSelectedMinite() {  
            return ((Integer) minuteSpin.getValue()).intValue();  
        }  
  
        private int getSelectedSecond() {  
            return ((Integer) secondSpin.getValue()).intValue();  
        }  
  
        private void dayColorUpdate(boolean isOldDay) {  
            Calendar c = getCalendar();  
            int day = c.get(Calendar.DAY_OF_MONTH);  
            c.set(Calendar.DAY_OF_MONTH, 1);  
            int actionCommandId = day - 2 + c.get(Calendar.DAY_OF_WEEK);  
            int i = actionCommandId / 7;  
            int j = actionCommandId % 7;  
            if (isOldDay) {  
                daysButton[i][j].setForeground(dateFontColor);  
            } else {  
                daysButton[i][j].setForeground(todayBackColor);  
            }  
        }  
  
        private void flushWeekAndDay() {  
            Calendar c = getCalendar();  
            c.set(Calendar.DAY_OF_MONTH, 1);  
            int maxDayNo = c.getActualMaximum(Calendar.DAY_OF_MONTH);  
            int dayNo = 2 - c.get(Calendar.DAY_OF_WEEK);  
            for (int i = 0; i < 6; i++) {  
                for (int j = 0; j < 7; j++) {  
                    String s = "";  
                    if (dayNo >= 1 && dayNo <= maxDayNo) {  
                        s = String.valueOf(dayNo);  
                    }  
                    daysButton[i][j].setText(s);  
                    dayNo++;  
                }  
            }  
            dayColorUpdate(false);  
        }  
  
        /** 
         * Ñ¡ÔñÈÕÆÚʱµÄÏìӦʼþ 
         */  
        @Override  
        public void stateChanged(ChangeEvent e) {  
            JSpinner source = (JSpinner) e.getSource();  
            Calendar c = getCalendar();  
            if (source.getName().equals("Hour")) {  
                c.set(Calendar.HOUR_OF_DAY, getSelectedHour());  
                setDate(c.getTime());  
                return;  
            }  
            if (source.getName().equals("Minute")) {  
                c.set(Calendar.MINUTE, getSelectedMinite());  
                setDate(c.getTime());  
                return;  
            }  
            if (source.getName().equals("Second")) {  
                c.set(Calendar.SECOND, getSelectedSecond());  
                setDate(c.getTime());  
                return;  
            }  
  
            dayColorUpdate(true);  
  
            if (source.getName().equals("Year")) {  
                c.set(Calendar.YEAR, getSelectedYear());  
            } else if (source.getName().equals("Month")) {  
                c.set(Calendar.MONTH, getSelectedMonth() - 1);  
            }  
            setDate(c.getTime());  
            flushWeekAndDay();  
        }  
  
        /** 
         * Ñ¡ÔñÈÕÆÚʱµÄÏìӦʼþ 
         */  
        @Override  
        public void actionPerformed(ActionEvent e) {  
            JButton source = (JButton) e.getSource();  
            if (source.getText().length() == 0) {  
                return;  
            }  
            dayColorUpdate(true);  
            source.setForeground(todayBackColor);  
            int newDay = Integer.parseInt(source.getText());  
            Calendar c = getCalendar();  
            c.set(Calendar.DAY_OF_MONTH, newDay);  
            setDate(c.getTime());  
            //°ÑdaySpinÖеÄÖµÒ²±äÁË  
            daySpin.setValue(Integer.valueOf(newDay));  
        }  
    }  
   
}