gpt4 book ai didi

java - 使用 swing 包的简单 java 表单需要日历中的指导吗?

转载 作者:行者123 更新时间:2023-12-02 07:31:36 34 4
gpt4 key购买 nike

我使用 java swing 包创建了一个注册表,为了在表单中添加出生日期,我使用了以下代码,特别是通过 Swing 包添加 JFrame。有没有其他方法可以简化代码。

JLabel l2 = new JLabel("Date of Birth");

l2.setBounds(200,160,100,20);
String day[] ={"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"};
String month[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
String year[] = {"2012","2011","2010","2009","2008","2007","2006","2005","2004","2003","2002","2001","2000","1999","1998","1997","1996","1995","1994","1993","1992","1991","1990","1989","1988","1987","1986","1985","1984","1983","1982","1981","1980","1979","1976","1975"};
JComboBox cb1 = new JComboBox(day);
cb1.setBounds(450,160,50,20);
JComboBox cb2 = new JComboBox(month);
cb2.setBounds(500,160,50,20);
JComboBox cb3 = new JComboBox(year);
cb3.setBounds(550,160,60,20);

最佳答案

这是我几年前编写的日历选择器的源代码。我没有包含所有依赖项,例如图形文件等,但我很确定您可以找出缺少的内容并重现它。我为一家公司的一个部门编写了它,该部门关闭了该部门,所以我怀疑是否有人会声称它的版权。

http://dl.dropbox.com/u/15266/SmallCalendar.java

http://dl.dropbox.com/u/15266/DateFormatInfo.java

请注意,SmallCalendar 包含一个 main,因此您可以测试它并查看它的调用方式。关于区域设置非常好。

关于java - 使用 swing 包的简单 java 表单需要日历中的指导吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12843459/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com