⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jdaylabel.java

📁 java+sql 图书管理系统
💻 JAVA
字号:
package MyLibraryok.borrow.ziliao;import java.text.*;import java.util.Date;import java.awt.*;import javax.swing.*;/** * <p>Title: JDatePicker</p> * <p>Description:JDayLable 带选择日期功能的JLabel </p> * <p>Copyright: Copyright (c) 2004</p> * <p>Company: </p> * @author <a href="mailto:sunkingxie@hotmail.com"'>Sunking</a> * @version 1.0 */public class JDayLabel extends JLabel{    private static ImageIcon todayIcon =new ImageIcon("today.gif");    Date date = null;    ImageIcon currentIcon = null;    /**     * 日期格式(TODAY/TIP用)     */    final SimpleDateFormat dateFormat        = new SimpleDateFormat("yyyy/MM/dd");    /**     * 日格式     */    final SimpleDateFormat dayFormat = new SimpleDateFormat("d");    public JDayLabel(Date date){        this(date, true);    }    public JDayLabel(Date date, boolean isSmallLabel){        setPreferredSize(new Dimension(40, 20));        setToolTipText(dateFormat.format(date));        this.date = date;        if(isSmallLabel){            setHorizontalAlignment(JLabel.CENTER);            setText(dayFormat.format(date));            Date d = new Date();            if(dateFormat.format(date).equals(dateFormat.format(d))){                currentIcon = todayIcon;            }        } else{            setText("Today:" + dateFormat.format(new Date()));            setIcon(todayIcon);            setHorizontalAlignment(JLabel.LEFT);        }    }    public Date getDate(){        return date;    }    public void setDate(Date date){        this.date = date;    }    public void paint(Graphics g){        super.paint(g);        if(currentIcon != null && isEnabled()){            int x = (this.getWidth() - currentIcon.getIconWidth()) / 2;            int y = (this.getHeight() - currentIcon.getIconHeight()) / 2;            currentIcon.paintIcon(this, g, x, y);        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -