Java Swing的日历控件谁有啊!

ling8280 2010-03-31 11:15:25
我现在需要一个Swing的日历控件,哪位有的话帮帮忙!
...全文
298 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
kbyst 2010-03-31
  • 打赏
  • 举报
回复
好啊,还想自己写一个呢,原来还有开源的~~
py330316117 2010-03-31
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 icy_csdn 的回复:]

有开源的,

http://sourceforge.net/projects/datepicker/
[/Quote]

MyEclipse中的matisse中有这个swing控件啊
gentalguo 2010-03-31
  • 打赏
  • 举报
回复
我有jdk1.6的,自己写的。自己写也并不复杂啊。
icy_csdn 2010-03-31
  • 打赏
  • 举报
回复
有开源的,

http://sourceforge.net/projects/datepicker/
孤独剑客 2010-03-31
  • 打赏
  • 举报
回复
你的JDK版本是多少, 我有, 我上传到我的资源, 自己去找
猿敲月下码 2010-03-31
  • 打赏
  • 举报
回复
看下这个吧

package com.gui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Calendar;
import java.util.GregorianCalendar;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class MyRiLi extends JPanel {

protected int yy;

protected int mm, dd;

/** 存放按钮 */
protected JButton labs[][];

/** 每个月份开头的几个空白日期 */
protected int leadGap = 0;

/** 日期对象 */
Calendar calendar = new GregorianCalendar();

/** 年份 */
protected final int thisYear = calendar.get(Calendar.YEAR);

/** 月份 */
protected final int thisMonth = calendar.get(Calendar.MONTH);

/** 取消按钮高亮时以这个按钮为基准 */
private JButton b0;

/** 存放月份 */
private JComboBox monthChoice;

/** 存放年份 */
private JComboBox yearChoice;

/**
* 构造方法,获取今天的日期
*/
MyRiLi() {
super();
setYYMMDD(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),
calendar.get(Calendar.DAY_OF_MONTH));
buildGUI();
recompute();
}

MyRiLi(int year, int month, int today) {
super();
setYYMMDD(year, month, today);
buildGUI();
recompute();
}

private void setYYMMDD(int year, int month, int today) {
yy = year;
mm = month;
dd = today;
}

String[] months = { "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月",
"十月", "十一月", "十二月" };

private void buildGUI() {
getAccessibleContext().setAccessibleDescription("日历未上载");
setBorder(BorderFactory.createEtchedBorder());

setLayout(new BorderLayout());

JPanel tp = new JPanel();
tp.add(monthChoice = new JComboBox());
for (int i = 0; i < months.length; i++)
monthChoice.addItem(months[i]);
monthChoice.setSelectedItem(months[mm]);
monthChoice.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
int i = monthChoice.getSelectedIndex();
if (i >= 0) {
mm = i;
recompute();
}
}
});
monthChoice.getAccessibleContext().setAccessibleName("Months");
monthChoice.getAccessibleContext().setAccessibleDescription("选择一个月份");

tp.add(yearChoice = new JComboBox());
yearChoice.setEditable(true);
for (int i = yy - 5; i < yy + 5; i++)
yearChoice.addItem(Integer.toString(i));
yearChoice.setSelectedItem(Integer.toString(yy));
yearChoice.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
int i = yearChoice.getSelectedIndex();
if (i >= 0) {
yy = Integer.parseInt(yearChoice.getSelectedItem()
.toString());
recompute();
}
}
});
add(BorderLayout.CENTER, tp);

JPanel bp = new JPanel();
bp.setLayout(new GridLayout(7, 7));
labs = new JButton[6][7];

// 星期
bp.add(b0 = new JButton("日"));
bp.add(new JButton("一"));
bp.add(new JButton("二"));
bp.add(new JButton("三"));
bp.add(new JButton("四"));
bp.add(new JButton("五"));
bp.add(new JButton("六"));

ActionListener dateSetter = new ActionListener() {
public void actionPerformed(ActionEvent e) {
String num = e.getActionCommand();
if (!num.equals("")) {
// 将当前日期高亮
setDayActive(Integer.parseInt(num));
}
}
};

// 创建所有的按钮
for (int i = 0; i < 6; i++)
for (int j = 0; j < 7; j++) {
bp.add(labs[i][j] = new JButton(""));
labs[i][j].addActionListener(dateSetter);
}

add(BorderLayout.SOUTH, bp);
}

// 列出每个月的天数
public final static int dom[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31,
30, 31 };

/** 计算每个月份的日期,显示在面板上 */
protected void recompute() {
if (mm < 0 || mm > 11)
throw new IllegalArgumentException("月份 " + mm + " 必须在0-11之间");
clearDayActive();
calendar = new GregorianCalendar(yy, mm, dd);

// 计算每个月份开头的几个空白日期
leadGap = new GregorianCalendar(yy, mm, 1).get(Calendar.DAY_OF_WEEK) - 1;

int daysInMonth = dom[mm];
if (isLeap(calendar.get(Calendar.YEAR)) && mm > 1)
++daysInMonth;

for (int i = 0; i < leadGap; i++) {
labs[0][i].setText("");
}

// 填入日期数字
for (int i = 1; i <= daysInMonth; i++) {
JButton b = labs[(leadGap + i - 1) / 7][(leadGap + i - 1) % 7];
b.setText(Integer.toString(i));
}

for (int i = leadGap + 1 + daysInMonth; i < 6 * 7; i++) {
labs[(i) / 7][(i) % 7].setText("");
}

if (thisYear == yy && mm == thisMonth)
setDayActive(dd);

repaint();
}

/**
* 判断是否闰年
*/
public boolean isLeap(int year) {
if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
return true;
return false;
}

/** 设置年月日 */
public void setDate(int yy, int mm, int dd) {
this.yy = yy;
this.mm = mm;
this.dd = dd;
recompute();
}

/** 取消按钮高亮 */
private void clearDayActive() {
JButton b;

if (activeDay > 0) {
b = labs[(leadGap + activeDay - 1) / 7][(leadGap + activeDay - 1) % 7];
b.setBackground(b0.getBackground());
b.repaint();
activeDay = -1;
}
}

private int activeDay = -1;

/** 设置按钮高亮 */
public void setDayActive(int newDay) {

clearDayActive();

if (newDay <= 0)
dd = new GregorianCalendar().get(Calendar.DAY_OF_MONTH);
else
dd = newDay;
Component square = labs[(leadGap + newDay - 1) / 7][(leadGap + newDay - 1) % 7];
square.setBackground(Color.red);
square.repaint();
activeDay = newDay;
}

public static void main(String[] av) {
JFrame f = new JFrame("MyRiLi");
Container c = f.getContentPane();
c.setLayout(new FlowLayout());

c.add(new MyRiLi());

f.pack();
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

}
串联谐振双有源桥(SR-DAB)DC-DC变换器闭环仿真研究内容概要:本文围绕串联谐振双有源桥(SR-DAB)DC-DC变换器的闭环仿真展开研究,重点探讨其在电力电子系统中的动态响应特性与控制策略。通过对SR-DAB变换器建立数学模型,并结合Matlab/Simulink进行闭环仿真,分析系统在不同工作条件下的电压、电流波形及功率传输效率,验证控制算法的有效性与稳定性。研究涵盖系统建模、控制器设计(如PI控制)、软开关实现条件、抗干扰能力以及动态调节性能,旨在提升变换器在新能源、储能、数据中心供电等场景中的可靠性和能效水平。; 适合人群:具备电力电子、自动控制理论基础,从事新能源、微电网、电力系统仿真等相关领域的科研人员与工程技术人员。; 使用场景及目标:①用于高校及科研机构开展DC-DC变换器控制策略的教学与实验;②为工业界在高效率隔离型功率变换系统的设计与优化提供仿真依据和技术支撑;③服务于数据中心、电动汽车、可再生能源并网等场景下的电源系统研发。; 阅读建议:建议读者结合Matlab代码实践仿真流程,重点关注系统建模与控制器参数整定部分,通过调整负载、输入电压等条件观察系统响应,深入理解闭环控制对变换器性能的影响机制。
内容概要:本文介绍了FastReport VCL/FMX/LCL 2026.2.4版本的更新内容,重点涵盖核心引擎、图形处理、用户界面及导出功能的优化与修复。主要更新包括修复了Developer Express兼容性问题、TfrxSVGGraphic在TImage中的显示问题、PDF/A导出合规性、EMF图像旋转异常,以及ReportTree拖拽功能等问题。同时,部分模块新增了HTMLTags对XLSX导出的支持、内置右键菜单和新图标,并改进了FastCube组件的元素调整体验。此外,还修复了CPP脚本中Result参数名的Bug以及自定义过滤器中OR操作失效的问题。; 适合人群:使用Delphi或Lazarus进行开发,且涉及报表设计与数据展示功能的中高级开发者;尤其适用于需要集成FastReport控件到企业级应用中的技术人员。; 使用场景及目标:①提升报表系统在不同平台(VCL/FMX/LCL)下的稳定性和兼容性;②满足PDF/A标准的文档归档需求;③优化用户交互体验,如拖拽操作与元素缩放;④增强脚本支持与数据集字段识别能力,确保开发效率与功能完整性。; 阅读建议:建议结合官方更新链接和实际项目中使用的FastReport模块对照查看,重点关注自身所用组件(如VCL、FMX或Lazarus版)的具体修复项,及时升级以规避已知问题并利用新特性优化报表功能。

62,621

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧