The MDateSelector is a 100% Java Swing Component that provides a Calendar to allow dates to be 'picked off' and returned to the date entry field on the Frame. The field can be used with or without the button since activation can also be performed using ALT-down arrrow key.
Once activated the calendar is shown below the text field if it will fit. The component will do its best to display the calendar, it may need create a heavyweight popup which overlaps the application frame.
Using this sort of control allows only valid dates to be entered and can remove the need for some validation. It was written to demostrate several techniques. The calendar is a MDateSelectorPanel which may be used in any Swing application, it is a JavaBean and can be demonstrated in the BeanBox. Features
UsageThe following code snippet shows one of my test classes that activates the MDateSelector on a push of the button or typing ALT-Down. This can be run by typing
java -jar MDateSelector.jar
in the directory containing the jar file.
MDateEntryField entryField = new MDateEntryField();
MDateSelectorConstraints c = new MDefaultPullDownConstraints();
c.firstDay = Calendar.MONDAY;
entryField.setConstraints(c);
entryField.addMFieldListener(new MFieldListener(){
public void fieldEntered(FocusEvent e)
{
System.out.println("Entered");
}
public void fieldExited(FocusEvent e)
{
System.out.println("Exited");
}
});
frame.getContentPane().add(entryField);
c.changerStyle=MDateChanger.SPINNER; to get the changer with two spinner fields. |
|
|
DownloadsThe jar, source code and javadocs may be downloaded from the downloads page
|