欢迎来到天天文库
浏览记录
ID:38259888
大小:39.72 KB
页数:13页
时间:2019-06-07
《Java 日期选择器》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Java日期选择器效果如图:importjava.awt.BasicStroke;importjava.awt.BorderLayout;importjava.awt.Color;importjava.awt.Component;importjava.awt.Cursor;importjava.awt.Dimension;importjava.awt.Font;importjava.awt.Graphics;importjava.awt.Graphics2D;importjava.awt.GridLayout;importjava.awt.Point;importjava.
2、awt.Polygon;importjava.awt.Stroke;importjava.awt.Toolkit;importjava.awt.event.FocusEvent;importjava.awt.event.FocusListener;importjava.awt.event.MouseAdapter;importjava.awt.event.MouseEvent;importjava.awt.event.MouseListener;importjava.awt.event.MouseMotionListener;importjava.text.SimpleDa
3、teFormat;importjava.util.ArrayList;importjava.util.Calendar;importjava.util.Comparator;importjava.util.Date;importjava.util.List;importjavax.swing.BorderFactory;importjavax.swing.JButton;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JPanel;importjavax.swing.Popup;impo
4、rtjavax.swing.PopupFactory;importjavax.swing.SwingUtilities;importjavax.swing.event.AncestorEvent;importjavax.swing.event.AncestorListener;publicclassDateChooserextendsJPanel{ privateDateinitDate; privateCalendarnow=Calendar.getInstance(); privateCalendarselect; privateJPanelmo
5、nthPanel;//月历 privateJP1jp1;//四块面板,组成 privateJP2jp2; privateJP3jp3; privateJP4jp4; privateFontfont=newFont("宋体",Font.PLAIN,12); privatefinalLabelManagerlm=newLabelManager(); privateJLabelshowDate;//,toSelect; privateSimpleDateFormatsdf=newSimpleDateFormat("yyyy年MM月d
6、d日"); privatebooleanisShow=false; privatePopuppop; publicDateChooser(){ this(newDate()); } publicDateChooser(Datedate){ initDate=date; select=Calendar.getInstance(); select.setTime(initDate); initPanel(); initLabel(); } pub
7、licvoidsetEnabled(booleanb){ super.setEnabled(b); showDate.setEnabled(b); } publicDategetDate(){ returnselect.getTime(); } //根据初始化的日期,初始化面板 privatevoidinitPanel(){ monthPanel=newJPanel(newBorderLayout()); m
此文档下载收益归作者所有