import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Calendar;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.UIManager;

import org.gui.JCalendarCombo;

public class CalendarTest extends JFrame
{
	CalendarTest()
	{
		JPanel panel1 = new JPanel();
		JLabel label1 = new JLabel("Name : ");
		JLabel label2 = new JLabel("Birth Date : ");
		JLabel label3 = new JLabel("Sun Sign : ");
		JTextField name = new JTextField();
		final JCalendarCombo jCalendarCombo = new JCalendarCombo(JCalendarCombo.MONDAY, true, 1900, 3000, false);
		jCalendarCombo.setDateFormat(JCalendarCombo.YEAR_BIG, JCalendarCombo.MONTH, JCalendarCombo.DAY, '-');

		Calendar calendar = Calendar.getInstance();
		calendar.set(2003, 4, 4);
		/* New Method added in JCalendarCombo 4*/
		jCalendarCombo.setDate(calendar);
		/* New Method added in JCalendarCombo 4*/
		//jCalendarCombo.setEnabled(false);

		JTextField sign = new JTextField();
		JButton okay = new JButton("OK");
		JButton cancel = new JButton("Cancel");
		panel1.setLayout(new GridLayout(4,2,5,5));
		getContentPane().setLayout(new GridLayout(1,1));
		panel1.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
		panel1.add(label1);
		panel1.add(name);
		panel1.add(label2);
		panel1.add(jCalendarCombo);
		panel1.add(label3);
		panel1.add(sign);
		panel1.add(okay);
		panel1.add(cancel);
		getContentPane().add(panel1);
		pack();
		setTitle("JCalendarCombo Demo");		
		setVisible(true);
		
		okay.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent e)
			{
				System.out.println(jCalendarCombo.getSelectedDate());
				System.out.println(jCalendarCombo.getSelectedDay());
				System.out.println(jCalendarCombo.getSelectedMonth());
				System.out.println(jCalendarCombo.getSelectedYear());

				/*New Method added in JCalendarCombo 4*/
				Calendar calendar = jCalendarCombo.getDate();

				System.out.println(calendar.get(Calendar.DAY_OF_MONTH)+" - "+calendar.get(Calendar.MONTH)+" - "+calendar.get(Calendar.YEAR));
			}
			
		});
		
		cancel.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent e)
			{
				System.exit(0);
			}
		});				

		addWindowListener(new WindowAdapter()
		{
			public void windowClosing(WindowEvent e)
			{
				System.exit(0);
			}
		});
	
	}
	public static void main(String args[]) throws Exception
	{
		UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		CalendarTest test = new CalendarTest();
	}
}	
