JDateComboBox

Screenshots | Demo | Download | Documentation

Swing ComboBox with calendar pop-up derived from PSwing DateComboBox

About

This package displays a Look&Feel independent Swing Component that represents a fully localised and editable JComboBox with calendar pop-up for Java 1.5 and later.
Localisation is automated and the interface most easy to use.
But look yourself at this screen shot of Japanese, German locale and CDE/Motif, Metal and System Look & Feel on my English Mac OS X:
JDateComboBox Japanese Locale JDateComboBox German Locale
JDateComboBox different look and feels

JDateComboBox supersedes PSwing DateComboBox which was intended for English language and a small set of Look & Feels (WinLAF, Motif, Metal) only and worked on many platforms with Java 1.2, 1.3 and 1.4.

License Agreement

The package is distributed under LGPL 3 and can be used freely with commercial software.

Code used to draw the JApplet displaying the Swing JDateComboBox shown above


public class Applet extends JApplet {

	public Applet() {
		Panel panel;

		setLayout(new FlowLayout());
		// Locales to be looped through
		Locale[]  loc = new Locale[3];
		loc[0] = Locale.getDefault();
		loc[2] = Locale.GERMANY;
		loc[1] = Locale.JAPANESE;

		int i = 0;

		// loop through Look and Feels
		for (UIManager.LookAndFeelInfo laf : UIManager
				.getInstalledLookAndFeels()) {
			try {
				UIManager.setLookAndFeel(laf.getClassName());
				Locale.setDefault(loc[i++ % 3]);
				
				panel = new Panel();
				getContentPane().add(panel);
			} catch (Exception e) {
			}
		}

		setVisible(true);
	}

	class Panel extends JPanel {
		private JDateComboBox date = null;

		public Panel() {
			JPanel panel = new JPanel();
			panel = new JPanel();
			date = new JDateComboBox(new Date());
			date.addFormat(DateFormat.getDateInstance(DateFormat.MEDIUM));
			panel.add(new JLabel("JDateComboBox:"));
			panel.add(date);
			add(panel);
		}
	}
}

History

This package is roughly based upon the LGPLed PSwing DateComboBox from 2003 which is extended here and tuned to be independent of the ComboBoxUI used in the old version.
This way it fixes some of the problems caused by unsupported platforms like MacOS X and can be considered platform independent. Since much of the underlying code has changed I do no longer include the PSwing class but refer to the original copyright holder in both classes derived from his code.


Last Updated: 3 Mar 2008

This software is distributed under:
lgpl v3 icon

Andere Sprache

EN