MSeries.ui.MDateEntryField


back

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

  • Programmable upper and lower date limits with defaults
  • Programmable colours for certain days and for specific dates.
  • Programmable date format for display and entry
  • Complete mouseless operation using keyboard
  • 100% Java (JDK1.3.1)
  • Pluggable Look & Feel with defaults
  • Popup will overlap the applications window if it needs to
  • The month & year changer can be either the scrollbar or two spinner fields
  • Works well in an Applet using the JDK1.3.0 Java Plug-in

Usage

The 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);


A new constraint has been added to switch the month/year changer. use

       c.changerStyle=MDateChanger.SPINNER;

to get the changer with two spinner fields.


The same component with the changer style set to SPINNER

The same components with the changer style set to BUTTON

 

Downloads

The jar, source code and javadocs may be downloaded from the downloads page