分享一个支持时分秒的Java时间控件

来源:互联网 发布:数据采集与无线传输 编辑:程序博客网 时间:2024/05/17 01:14

  最近要做一个支持跨平台桌面应用程序,想都没想就用了Java,可正好要用到时间控件时却发愁了 因为有需要精确的秒钟,网上搜了很多没有找到满意的。就找了个看得过去的开源控件,自己修改了。废话就不多说了,直接上图:

样子是丑了点不过还能用,(*^__^*) 嘻嘻……


这个Look&Feel好一点 不过布局有点乱 暂时不管了

以下是测试代码:

JFrame frame = new JFrame("JDateChooser");JDateChooser dateChooser = new JDateChooser();dateChooser.jcalendar.setNullDateButtonVisible(true);dateChooser.jcalendar.setTodayButtonVisible(true);dateChooser.jcalendar.setDoneButtonVisible(true);dateChooser.jcalendar.setHourSliderVisible(true);dateChooser.jcalendar.setMinuteSliderVisible(true);dateChooser.jcalendar.setSecondSliderVisible(true);// JDateChooser dateChooser = new JDateChooser(null, new Date(), null,// null);//dateChooser.setLocale(new Locale("de"));//dateChooser.setDateFormatString("dd. MMMM yyyy");// dateChooser.setPreferredSize(new Dimension(130, 20));// dateChooser.setFont(new Font("Verdana", Font.PLAIN, 10));dateChooser.setDateFormatString("yyyy-MM-dd HH:mm:ss");// URL iconURL = dateChooser.getClass().getResource(// "/com/toedter/calendar/images/JMonthChooserColor32.gif");// ImageIcon icon = new ImageIcon(iconURL);// dateChooser.setIcon(icon);frame.getContentPane().add(dateChooser);frame.pack();frame.setVisible(true);dateChooser.requestFocusInWindow();frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

源代码下载地址:

http://download.csdn.net/detail/kings988/4660366


原创粉丝点击