Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java GUI 设计  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 Jave 日期选择控件 DateChooser
OneFox





发贴: 1
积分: 10
于 2003-10-31 10:49 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list


http://www.javaresearch.org/article/showarticle.jsp?column=287&thread=9998



作者 Re:Jave 日期选择控件 DateChooser [Re:OneFox]
dapan



CJSDN高级会员


发贴: 929
积分: 80
于 2003-10-31 12:03 user profilesend a private message to usersend email to dapansearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Welcome to CJSDN!

^_^

Java 日期选择控件 DateChooser
特点:
比较漂亮,默认的配色跟我桌上的日历本一样。
你也可以自己修改配色。
使用方便,两三行代码就ok了
控制条里的按钮按住半秒后会快速翻动
类似的控件好像 VB VC 里有, Java 的见过一个,
不好看,使用也不方便。
+++++++++++++++++++++++++++++++++++++++++++++++++
[Test.java] 测试类
==== package datechooser ====
[DateChooser.java] Java 日期选择控件(主体类) [public]
[TablePanel.java] 日历表格面板
[ConfigLine.java] 控制条类
[RoundBox.java] 限定选择控件
[MonthMaker.java] 月份表算法类
[Pallet.java] 调色板,统一配色类 [public]
+++++++++++++++++++++++++++++++++++++++++++++++++

/**
* [Test.java]
*
* 测试类
*
* 创建日期:(2003-10-26)
* @author:ONE_Fox
* @author:ONE_Fox@163.com
*/


import datechooser.DateChooser;
import datechooser.Pallet;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

import java.util.Date;
import java.text.SimpleDateFormat;



public class Test extends JFrame {


//界面组件----------------//
private JTextField showField = new JTextField(15);
private JButton testButton = new JButton("Tset Button");


//有父窗口(Farm),不带日期参数的 DateChooser
private DateChooser dateChooser = new DateChooser(this);

/**
* **其他构造方法**
**
//无父窗口,不带日期参数的 DateChooser
new DateChooser();

//有父窗口,带日期参数的 DateChooser
new DateChooser(Frame owner, Calendar showMonth, int startYear,
int lastYear);

//无父窗口,带日期参数的 DateChooser
new DateChooser(Calendar showMonth, int startYear, int lastYear);
*/



/**
* **界面配色**
**

static {

Pallet.backGroundColor = Color.gray; //底色


//月历表格配色----------------//
Pallet.palletTableColor = Color.white; //日历表底色
Pallet.todayBackColor = Color.pink; //今天背景色

Pallet.weekFontColor = Color.white; //星期文字色
Pallet.dateFontColor = Color.black; //日期文字色
Pallet.weekendFontColor = Color.red; //周末文字色


//控制条配色------------------//
Pallet.configLineColor = Color.pink; //控制条底色
Pallet.cfgTextColor = Color.white; //控制条标签文字色

Pallet.rbFontColor = Color.white; //RoundBox文字色
Pallet.rbBorderColor = Color.red; //RoundBox边框色
Pallet.rbButtonColor = Color.pink; //RoundBox按钮色
Pallet.rbBtFontColor = Color.red; //RoundBox按钮文字色
}
*/





//------构造方法-------------------------------------------------//
public Test() {

makeFace(); //界面制作
addListener(); //添加事件监听

show(); //界面显示
}




//------方法/函数------------------------------------------------//


public void makeFace() {

setTitle("Test DateChooser");

setLocation(100, 100);
setSize(300, 200);

getContentPane().setLayout(new FlowLayout());

getContentPane().add(showField);
getContentPane().add(testButton);
}


public void addListener() {

testButton.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {

//设置显示显示位置相对与一个界面组件
dateChooser.showChooser(testButton,
e.getX() - DateChooser.width, e.getY());

/**
* 设置固定的显示位置
**

dateChooser.showChooser(null, 300, 300);

*/


//取得选择的日期
Date theDay = dateChooser.getDate();

/**
* showChooser()方法也返回 Date 日期
**

Date theDay = dateChooser.showChooser(null, 300, 300);

*/



//输出至文本框显示
if(theDay != null)
showField.setText(new SimpleDateFormat("[ yyyy年M月d日]")
.format(theDay));
}
});



this.addWindowListener(new WindowAdapter(){ //添加窗口关闭事件
public void windowClosing(WindowEvent e){

setVisible(false);
dispose();

System.exit(0);
}
});
}



//------程序入口-------------------------------------------------//


public static void main(String[] args) {

//启动测试------------//
new Test();
}
}


datechooser.zip (27.17k)


dapan edited on 2003-10-31 12:13

作者 Re:Jave 日期选择控件 DateChooser [Re:OneFox]
Jove



CJSDN高级会员


发贴: 1228
积分: 194
于 2003-10-31 16:06 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
3xs

那我也贴一个SWT版的



作者 Re:Jave 日期选择控件 DateChooser [Re:Jove]
Jove



CJSDN高级会员


发贴: 1228
积分: 194
于 2003-10-31 16:18 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
原连接 http://eclipsewiki.swiki.net/159
略有修改
使用方法 new DatePickerCombo(topComposite,SWT.BORDER | SWT.READ_ONLY);

DatePicker.zip (7.42k)



作者 Re:Jave 日期选择控件 DateChooser [Re:OneFox]
Julian13





发贴: 387
积分: 52
于 2003-11-02 00:11 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
one here too:
http://www.cjsdn.com/post/view?bid=21&id=48365&sty=1&tpg=1&age=0

BTW, is there anyone offer time selection as well?



who am i?
作者 Re:Jave 日期选择控件 DateChooser [Re:OneFox]
yb79528





发贴: 104
积分: 10
于 2003-11-03 09:09 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
好东西,在
http://www.javaresearch.org/article/showarticle.jsp?column=287&thread=8907

http://www.javaresearch.org/article/showarticle.jsp?column=287&thread=8872

还有Onefox的另两篇原创的文章,推荐




flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923