Java – JCalendar for Date Selection

Previously i have created two posts about a simple Swing Date Picker.

 

Here comes a better solution – JCalendar.

JCalendar is Java Bean which provides a complete feature of a Date Picker in Java. For more information, please visit JCalendar Java Bean, a Java Date Chooser

The following only shows the basic usage of JCalendar. Hope you could explore its full features base on it.
1. Download the JCalendar.jar @ here

2. Create the following class and run it
Demo.java

import java.awt.EventQueue;
import javax.swing.JFrame;
import com.toedter.calendar.JDateChooser;

public class Demo {

  private JFrame frame;

  /**
   * Launch the application.
   */
  public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
      public void run() {
       try {
          Demo window = new Demo();
          window.frame.setVisible(true);
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
    });
  }

  /**
   * Create the application.
   */
  public Demo() {
    initialize();
  }

  /**
   * Initialize the contents of the frame.
   */
  private void initialize() {
    frame = new JFrame();
    frame.setBounds(100, 100, 450, 300);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().setLayout(null);
		
    JDateChooser dateChooser = new JDateChooser();
    dateChooser.setBounds(20, 20, 200, 20);
    frame.getContentPane().add(dateChooser);
  }
}

 

3. See what you get

 

Done =)

Reference: JCalendar Java Bean, a Java Date Chooser