/**
*
* Copyright: Ares.
* All Rights Reserved.
* Company: Insigma HT/上海创图
* @author Ares <a href="mailto:icerainsoft@hotmail.com>send email</a>
* @date 2013-11-17 16:53
*
* Revision History
*
* Date Programmer Notes
* --------- --------------------- --------------------------------------------
* 2013-11-17 Ares initial
* 2014-09-16 Ares fix bug @n3k123
*
* 1. you can change date format by parameter.
* 2. you can change week label content by showTEXT.
* 3. you can change dayOfWeek order by defaultStartDAY.
*/
package com.artisan.util;
import java.awt.BasicStroke;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridLayout;
import java.awt.Point;
import java.awt.Polygon;
import java.awt.Stroke;
import java.awt.Toolkit;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.PopupFactory;
import javax.swing.SwingUtilities;
import javax.swing.event.AncestorEvent;
import javax.swing.event.AncestorListener;
/**
* @author Ares
* @Describe(Date Chooser class)
*/
public class Chooser extends JPanel{
private static final long serialVersionUID = -5384012731547358720L;
private Calendar calendar;
private Calendar now = Calendar.getInstance();
private JPanel calendarPanel;
private java.awt.Font font = new java.awt.Font("Times",java.awt.Font.PLAIN,12);
private java.text.SimpleDateFormat sdf;
private final LabelManager lm = new LabelManager();
private javax.swing.Popup pop;
private TitlePanel titlePanel;
private BodyPanel bodyPanel;
private FooterPanel footerPanel;
private JComponent showDate;
private boolean isShow = false;
private static final String DEFAULTFORMAT = "yyyy-MM-dd";
private static final String[] showTEXT = {"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
private static WeekLabel[] weekLabels = new WeekLabel[7];
private static int defaultStartDAY = 0;//0 is from Sun, 1 is from Mon, 2 is from Tue
private static Color hoverColor = Color.BLUE; // hover color
private Chooser(java.util.Date date, String format, int startDAY){
if(startDAY > -1 && startDAY < 7) defaultStartDAY = startDAY;
int dayIndex = defaultStartDAY;
for(int i=0; i<7; i++){
if(dayIndex > 6) dayIndex = 0;
weekLabels[i] = new WeekLabel(dayIndex, showTEXT[dayIndex]);
dayIndex ++ ;
}
sdf = new java.text.SimpleDateFormat(format);
calendar = Calendar.getInstance();
calendar.setTime(date);
initCalendarPanel();
}
public static Chooser getInstance(java.util.Date date, String format){
return new Chooser(date, format, defaultStartDAY);
}
public static Chooser getInstance(java.util.Date date){
return getInstance(date, DEFAULTFORMAT);
}
public static Chooser getInstance(String format){
return getInstance(new java.util.Date(), format);
}
public static Chooser getInstance(){
return getInstance(new java.util.Date(), DEFAULTFORMAT);
}
private void initCalendarPanel(){
calendarPanel = new JPanel(new java.awt.BorderLayout());
calendarPanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0xAA, 0xAA, 0xAA)));
calendarPanel.add(titlePanel = new TitlePanel(), java.awt.BorderLayout.NORTH);
calendarPanel.add(bodyPanel = new BodyPanel(), java.awt.BorderLayout.CENTER);
calendarPanel.add(footerPanel = new FooterPanel(),java.awt.BorderLayout.SOUTH);
this.addAncestorListener(new AncestorListener() {
public void ancestorAdded(AncestorEvent event) { }
public void ancestorRemoved(AncestorEvent event) {hidePanel();}
//hide pop when move component.
public void ancestorMoved(AncestorEvent event) {
hidePanel();
}
});
}
public void register(final JComponent showComponent) {
this.showDate = showComponent;
showComponent.setRequestFocusEnabled(true);
showComponent.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent me) {
showComponent.requestFocusInWindow();
}
});
this.add(showComponent, BorderLayout.CENTER);
this.setPreferredSize(new Dimension(90, 25));
this.setBorder(BorderFactory.createLineBorder(Color.GRAY));
showComponent.addMouseListener(new MouseAdapter() {
public void mouseEntered(MouseEvent me) {
if (showComponent.isEnabled()) {
showComponent.setCursor(new Cursor(Cursor.HAND_CURSOR));
}
}
public void mouseExited(MouseEvent me) {
if (showComponent.isEnabled()) {
showComponent.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
showComponent.setForeground(Color.BLACK);
}
}
public void mousePressed(MouseEvent me) {
if (showComponent.isEnabled()) {
showComponent.setForeground(hoverColor);
if (isShow) {
hidePanel();
} else {
showPanel(showComponent);
}
}
}
public void mouseReleased(MouseEvent me) {
if (showComponent.isEnabled()) {
showComponent.setForeground(Color.BLACK);
}
}
});
showComponent.addFocusListener(new FocusListener() {
public void focusLost(FocusEvent e) {
hidePanel();
}
public void focusGained(FocusEvent e) { }
});
}
//hide the main panel.
private void hidePanel() {
if (pop != null) {
isShow = false;
pop.hide();
pop = null;
}
}
//show the main panel.
private void showPanel(Component owner) {
if (pop != null) pop.hide();
Point show = new Point(0, showDate.getHeight());
SwingUtilities.convertPointToScreen(show, showDate);
Dimension size = Toolkit.getDefaultToolkit().getScreenSize();
int x = show.x;
int y = show.y;
if (x < 0) x = 0;
if (x > size.width - 212) x = size.width - 212;
if (y > size.height - 167) y -= 165;
pop = PopupFactory.getSharedInstance().getPopup(owner, calendarPanel, x, y);
pop.show();
isShow = true;
}
// change text or label's content.
private void commit() {
if (showDate instanceof JTextField) {
((JTextField) showDate).setText(sdf.format(calendar.getTime()));
}else if (showDate instanceof JLabel) {
((JLabel) showDate).setText(sdf.format(calendar.getTime()));
}
hidePanel();
}
// control panel
private class TitlePanel extends JPanel {
private static final long serialVersionUID = -2865282186037420798L;
private JLabel preYear,preMonth,center,nextMonth,nextYear,centercontainer;
public T
没有合适的资源?快使用搜索试试~ 我知道了~
常见的各类学生信息系统
共297个文件
class:156个
png:94个
java:41个
需积分: 0 2 下载量 168 浏览量
2024-01-19
21:32:19
上传
评论 1
收藏 7.86MB RAR 举报
温馨提示
1.学生信息管理系统 2.学生选课管理系统 3.学生签到考勤系统 4.学生成绩管理系统
资源推荐
资源详情
资源评论
收起资源包目录
常见的各类学生信息系统 (297个子文件)
StatsAttendanceFrm.class 15KB
ManageSelectedCourseFrm.class 14KB
StatsScoreFrm.class 13KB
ManageCourseFrm.class 13KB
ManageStudentFrm.class 13KB
ManageTeacherFrm.class 13KB
ManageScoreFrm.class 13KB
ManageAttendanceFrm.class 12KB
AttendanceStudentFrm.class 11KB
ManageClassFrm.class 10KB
MainFrm.class 9KB
AddScoreFrm.class 9KB
LoginFrm.class 9KB
Chooser.class 8KB
AddStudentFrm.class 8KB
ViewScoreFrm.class 8KB
EditPasswordFrm.class 8KB
AddCourseFrm.class 8KB
AddTeacherFrm.class 8KB
AddStudentClassFrm.class 6KB
Chooser$DayLabel.class 5KB
StudentDao.class 5KB
AttendanceDao.class 5KB
TeacherDao.class 5KB
SelectedCourseDao.class 5KB
ScoreDao.class 5KB
CourseDao.class 5KB
ClassDao.class 3KB
Chooser$TitlePanel.class 3KB
Chooser$BodyPanel.class 3KB
AdminDao.class 3KB
Chooser$LabelManager.class 2KB
DbUtil.class 2KB
Chooser$FooterPanel$1.class 2KB
Chooser$TitlePanel$MyMouseAdapter.class 2KB
Chooser$FooterPanel.class 2KB
StatsAttendanceFrm$5.class 2KB
StatsAttendanceFrm$6.class 2KB
Chooser$3.class 2KB
UserType.class 2KB
Course.class 2KB
Teacher.class 1KB
ManageScoreFrm$3.class 1KB
Student.class 1KB
ManageClassFrm$2.class 1KB
Attendance.class 1KB
StatsAttendanceFrm$4.class 1KB
Admin.class 1KB
MainFrm$11.class 1KB
MainFrm$12.class 1KB
MainFrm$13.class 1KB
MainFrm$14.class 1KB
MainFrm$10.class 1KB
MainFrm$4.class 1KB
MainFrm$8.class 1KB
MainFrm$17.class 1KB
MainFrm$6.class 1KB
MainFrm$18.class 1KB
MainFrm$16.class 1KB
MainFrm$3.class 1KB
MainFrm$9.class 1KB
MainFrm$7.class 1KB
MainFrm$15.class 1KB
Score.class 1KB
StudentClass.class 994B
ManageSelectedCourseFrm$5.class 948B
MainFrm$2.class 940B
AttendanceStudentFrm$4.class 930B
ManageStudentFrm$6.class 926B
ManageAttendanceFrm$6.class 924B
StatsAttendanceFrm$7.class 918B
ManageCourseFrm$6.class 913B
Chooser$1.class 911B
ManageTeacherFrm$6.class 907B
ManageClassFrm$6.class 894B
ViewScoreFrm$3.class 894B
ManageScoreFrm$7.class 894B
SelectedCourse.class 893B
Chooser$2.class 850B
StatsAttendanceFrm$3.class 832B
ManageSelectedCourseFrm$1.class 830B
AttendanceStudentFrm$1.class 815B
Chooser$4.class 812B
ManageAttendanceFrm$1.class 810B
AddStudentClassFrm$1.class 805B
StatsAttendanceFrm$1.class 805B
ManageSelectedCourseFrm$3.class 804B
ManageSelectedCourseFrm$7.class 803B
ManageSelectedCourseFrm$6.class 802B
ManageTeacherFrm$1.class 795B
ManageStudentFrm$1.class 795B
ManageSelectedCourseFrm$2.class 794B
ManageCourseFrm$1.class 790B
ManageClassFrm$1.class 785B
ManageScoreFrm$1.class 785B
AttendanceStudentFrm$2.class 781B
AddStudentFrm$1.class 780B
StatsScoreFrm$1.class 780B
AddTeacherFrm$1.class 780B
ManageAttendanceFrm$5.class 778B
共 297 条
- 1
- 2
- 3
资源评论
henaimaimai
- 粉丝: 8
- 资源: 16
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Python课设-学生信息管理系统
- 广东省2021年普通高考音乐表演-器乐类总分分数段统计表(含本、专科层次加分)
- ubuntu20.04安装教程.md
- 广东省2021年普通高考音乐表演-声乐类总分分数段统计表(含本、专科层次加分)
- 广东省2021年普通高考音乐学类总分分数段统计表(含本、专科层次加分)
- 广东省2021年普通高考舞蹈类总分分数段统计表(含本、专科层次加分)
- Python教程-快速入门基础必看课程10-函数基础
- tensorflow-2.9.2-cp39-cp39-win-amd64.whl
- tensorflow-2.9.2-cp37-cp37m-win-amd64.whl
- 广东省2021年普通高考体育类总分分数段统计表(含本、专科层次加分)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功