在网上收集的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
);
}
}
|
本文介绍了一个基于Swing的自定义日期时间选择组件,该组件支持日期上下按钮点击操作,并能够根据当前年份判断是否为闰年以显示正确的月份天数。文中提供了一个简单的示例程序用于展示组件的基本使用。
1032

被折叠的 条评论
为什么被折叠?



