SwingX JXDatePicker

JXDatePicker日历空间(日期选择器),比其他商业软件要好多了

 

/*
 * JTaskPaneTest.java
 *
 * Created on 2006年11月16日, 上午11:27
 
*/


package  l2fprod;
import  javax.swing. * ;
import  com.l2fprod.common.swing. * ;
import  java.awt. * ;
import  java.awt.event. * ;
import  java.text. * ;

/**
 *
 * 
@author  zwql
 
*/

public   class  JTaskPaneTest  extends  javax.swing.JFrame  {
    
    
/**
     * Creates new form JTaskPaneTest
     
*/

    
public JTaskPaneTest() {
        initComponents();
        jTaskPaneGroup1.setTitle(
"aaa is aa's son");        
        jTaskPaneGroup2.setTitle(
"xx is xxx's father");
        DateFormat[] dateFormat 
= new DateFormat[1];
        dateFormat[
0= new SimpleDateFormat("yyyy-MM-dd");
        jXDatePicker1.setFormats(dateFormat);
        jXDatePicker1.setDate(
null);
    }

    
    
    Action makeAction(String title, String tooltiptext, String iconPath) 
{
        Action action 
= new AbstractAction(title) {
            
public void actionPerformed(ActionEvent e) {}
        }
;
        action.putValue(Action.SMALL_ICON, 
new ImageIcon(iconPath));
        action.putValue(Action.SHORT_DESCRIPTION, tooltiptext);
        
return action;
    }

    
/** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     
*/

    
// <editor-fold defaultstate="collapsed" desc=" 生成的代码 ">                          
    private void initComponents() {
        jScrollPane1 
= new javax.swing.JScrollPane();
        jTaskPane1 
= new com.l2fprod.common.swing.JTaskPane();
        jTaskPaneGroup1 
= new com.l2fprod.common.swing.JTaskPaneGroup();
        jButton1 
= new javax.swing.JButton();
        jLinkButton1 
= new JLinkButton("xxxxx",new ImageIcon("d:/wqlfiles/icon/z.ico"));
        jTaskPaneGroup2 
= new com.l2fprod.common.swing.JTaskPaneGroup();
        jButton2 
= new javax.swing.JButton();
        jTextField1 
= new javax.swing.JTextField();
        jButton3 
= new javax.swing.JButton();
        jXDatePicker1 
= new org.jdesktop.swingx.JXDatePicker();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        jButton1.setText(
"jButton1");

        jLinkButton1.setText(
"jLinkButton1");
        jLinkButton1.addActionListener(
new java.awt.event.ActionListener() {
            
public void actionPerformed(java.awt.event.ActionEvent evt) {
                jLinkButton1ActionPerformed(evt);
            }

        }
);

        org.jdesktop.layout.GroupLayout jTaskPaneGroup1Layout 
= new org.jdesktop.layout.GroupLayout(jTaskPaneGroup1.getContentPane());
        jTaskPaneGroup1.getContentPane().setLayout(jTaskPaneGroup1Layout);
        jTaskPaneGroup1Layout.setHorizontalGroup(
            jTaskPaneGroup1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jButton1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 
209, Short.MAX_VALUE)
            .add(jLinkButton1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 
209, Short.MAX_VALUE)
        );
        jTaskPaneGroup1Layout.setVerticalGroup(
            jTaskPaneGroup1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jTaskPaneGroup1Layout.createSequentialGroup()
                .add(jLinkButton1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 
11, Short.MAX_VALUE)
                .add(jButton1))
        );

        jButton2.setText(
"jButton2");

        jTextField1.setText(
"jTextField1");

        jButton3.setText(
"jButton3");

        org.jdesktop.layout.GroupLayout jTaskPaneGroup2Layout 
= new org.jdesktop.layout.GroupLayout(jTaskPaneGroup2.getContentPane());
        jTaskPaneGroup2.getContentPane().setLayout(jTaskPaneGroup2Layout);
        jTaskPaneGroup2Layout.setHorizontalGroup(
            jTaskPaneGroup2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jButton2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 
209, Short.MAX_VALUE)
            .add(jTaskPaneGroup2Layout.createSequentialGroup()
                .add(
101010)
                .add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 
151, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jButton3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 
40, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(
454545))
        );
        jTaskPaneGroup2Layout.setVerticalGroup(
            jTaskPaneGroup2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jTaskPaneGroup2Layout.createSequentialGroup()
                .addContainerGap()
                .add(jTaskPaneGroup2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jButton3))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 
18, Short.MAX_VALUE)
                .add(jButton2))
        );

        org.jdesktop.layout.GroupLayout jTaskPane1Layout 
= new org.jdesktop.layout.GroupLayout(jTaskPane1);
        jTaskPane1.setLayout(jTaskPane1Layout);
        jTaskPane1Layout.setHorizontalGroup(
            jTaskPane1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jTaskPane1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jTaskPane1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, 
false)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, jTaskPaneGroup1, 
0, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, jTaskPaneGroup2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 
231, Short.MAX_VALUE))
                .addContainerGap())
        );
        jTaskPane1Layout.setVerticalGroup(
            jTaskPane1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jTaskPane1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jTaskPaneGroup1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(
393939)
                .add(jTaskPaneGroup2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(
94, Short.MAX_VALUE))
        );
        jScrollPane1.setViewportView(jTaskPane1);

        org.jdesktop.layout.GroupLayout layout 
= new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(
727272)
                .add(jXDatePicker1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 
119, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(
119, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .addContainerGap()
                        .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 
299, Short.MAX_VALUE))
                    .add(layout.createSequentialGroup()
                        .add(
383838)
                        .add(jXDatePicker1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        pack();
    }
// </editor-fold>                        

    
private void jLinkButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                             
// TODO 将在此处添加您的处理代码:
        JDirectoryChooser dc = new JDirectoryChooser();
        dc.showOpenDialog(
this);
    }
                                            
    
    
/**
     * 
@param args the command line arguments
     
*/

    
public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(
new Runnable() {
            
public void run() {
                
new JTaskPaneTest().setVisible(true);
            }

        }
);
    }

    
    
// 变量声明 - 不进行修改                     
    public javax.swing.JButton jButton1;
    
public javax.swing.JButton jButton2;
    
public javax.swing.JButton jButton3;
    
public com.l2fprod.common.swing.JLinkButton jLinkButton1;
    
public javax.swing.JScrollPane jScrollPane1;
    
public com.l2fprod.common.swing.JTaskPane jTaskPane1;
    
public com.l2fprod.common.swing.JTaskPaneGroup jTaskPaneGroup1;
    
public com.l2fprod.common.swing.JTaskPaneGroup jTaskPaneGroup2;
    
public javax.swing.JTextField jTextField1;
    
public org.jdesktop.swingx.JXDatePicker jXDatePicker1;
    
// 变量声明结束                   
    
}

代码是用netbeans写的,不便之处见谅,不过说真的,matiss真的很好用

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值