JAVA编写的小型日历

如果想要编写小型日历软件需要学会:有一定的Java基础,熟练运用Java的常用类和图形用户界面

因为我也是刚学习界面这块可能有点丑,代码应该也不是最简版的

运行图片:

可执行功能: 打开显示当前日期,在空白处输入日期(任意形式)可查询某年某月的日历,点击翻页按钮可查看上个月或下个月日历,点击返回当前月份显示当前月份的日历

代码链接:点击打开链接

ublic class JCalendar extends JPanel{ //动态表示年月日 private int year=0; private int month=0; private int day=0; private int first = 0; //用于标志日历面板是否显示 private static boolean isShow = false; //主面板 private JPanel Main = new JPanel(); //日面板 private JPanel jPanelDay = new JPanel(); //月面板 private JPanel jPanelMonth = new JPanel(); //月的输入位置 private JTextField Month = new JTextField(); //减少月份 private JButton MonthDown = new JButton(); //增加月份 private JButton MonthUp = new JButton(); private JPanel jPanelButton = new JPanel(); //减少年份 private JButton YearDown = new JButton(); //增加年份 private JButton YearUp = new JButton(); //显示日期的位置 private JLabel Out = new JLabel(); public JLabel Out2 = new JLabel(); private Locale l=Locale.CHINESE; //主日历 private GregorianCalendar cal=new GregorianCalendar(l); //星期面板 private JPanel weekPanel=new JPanel(); //天按钮组 private JToggleButton[] days=new JToggleButton[42]; //天面板 private JPanel Days = new JPanel(); //标示 private JLabel jLabel1 = new JLabel(); private JLabel jLabel2 = new JLabel(); private JLabel jLabel3 = new JLabel(); private JLabel jLabel4 = new JLabel(); private JLabel jLabel5 = new JLabel(); private JLabel jLabel6 = new JLabel(); private JLabel jLabel7 = new JLabel(); //当前选择的天数按钮 private JToggleButton cur=null; //月份天数数组,用来取得当月有多少天 // 1 2 3 4 5 6 7 8 9 10 11 12 private int[] mm={31,28,31,30,31,30,31,31,30,31,30,31}; //空日期构造函数 public JCalendar() { try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } //带日期设置的构造函数 public JCalendar(int year, int month, int day) { cal.set(year, month, day); try { jbInit(); } catch (Exception e) { e.printStackTrace(); }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值