Java Swing - Date Picker dialog to select a date

This is addressed to the few Java Swing developers, who may still be out there and looking for cool widgets.

How many times did you need a date picker widget? you know, like the one from the GWT for example, and there are many others available.

Unfortunatelly the Java Swing library doesn't have a built-in one. Anyways, I found a good starting point here, -- which is a very nicely done example, a little incomplete, but still good to go.

Because I wanted this widget to be perfect, I've updated and enhanced and it can do the followings:
  • automatic extract the name of the days and months from the Java locale (not like the original from a properties file).
  • automatic detects and display the first day of the week according with the used locale (not like the original that uses hard-coded only US style).
  • correct the coloring in red of the weekend days (not like original that had only Sundays on red, and Saturdays on gray). 
  • corrected the button images to have all the same size (better header than the original)
  • implemented the "close on away click" feature to easily close the picker dialog when click away.
These are the results of the Java Swing widget:


The first image is a read-only text-field and a button, which will open the date-picker dialog, as seen in the second image.

We can fast scroll though months and years, or quickly select from the 2 combos, and for the days just press on the date, which you want to select.

Hope you like it -- the source code is available here.


PS: you can see this widget at work, in my free application Money On Thread.


  1. Do you know the SwingX date picker component?

  2. Obviuosly I didn't know about that -- thank you -- I checked it out, indeed that JXDatePciker is very neat!


  3. ive done download ure source but i cant find the sccbutton and sccutil, help

  4. In the SccUtil helper you have this function, which you can drop it in the current java class:

    public static String convertFirstUpperChar(final String s) {
    return new StringBuilder().append(s.substring(0, 1).toUpperCase()).append(s.substring(1)).toString();

  5. --> for the SccButton, you can replace it with JButton.

  6. final LookAndFeel lf = new SubstanceBusinessBlackSteelLookAndFeel();
    this gives error...
    Any suggestions?

    1. comment out that line's just for the look and feel, aka cosmetic ... maybe you don't have the substance look and feel library.

  7. can you print the stack-trace ... it could be that you haven't launched the GUI app from the SwingUtilities.executeLater (...) thread.
    - I cannot guess like this, I need to see the error.