在网上收集的swing时间组件完善了一下,日期上下按钮可以点击,闰年平年判断,月份是多少天自动更新改变。希望大家继续完善。
MainApp
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
|
import
java.awt.Dimension;
import
java.awt.Toolkit;
import
java.awt.event.WindowAdapter;
import
java.awt.event.WindowEvent;
import
javax.swing.JButton;
import
javax.swing.JFrame;
import
javax.swing.JOptionPane;
import
javax.swing.JPanel;
public
class
MainApp
extends
JFrame {
public
static
int
x=
0
;
public
static
int
y=
0
;
/**
* @param args
*/
public
static
void
main(String[] args) {
JFrame jf =
new
JFrame();
JPanel tabPanel =
new
JPanel();
JButton timeButton =
new
DataChooser();
tabPanel.add(timeButton);
jf.add(tabPanel);
jf.setBounds(
350
,
200
,
500
,
400
);
jf.setVisible(
true
);
jf.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
jf.addWindowListener(
new
WindowAdapter(){
public
void
windowClosing(WindowEvent e){
int
n=JOptionPane.showConfirmDialog(
null
,
"确认退出吗?"
,
"确认对话框"
,
JOptionPane.YES_NO_OPTION );
if
(n==JOptionPane.YES_OPTION)
{System.exit(
0
);}
return
;
}});
jf.setEnabled(
true
);
}
}
|