Java Swing JXDatePicker

Tom picture Tom · Apr 19, 2013 · Viewed 28.7k times · Source

I'm using SwingX JXDatePicker and I can't figure out how to provide next/previous year buttons (as by default it only provides next/previous month buttons).

Also, it seems that SwingX is not maintained anymore: should I be using a more recent component as date picker?

Any help/hint would be greatly appreciated. Thanks, Thomas

UPDATE:

To clarify the question, I added a JXDatePicker screenshot and highlighted in red the next/previous month buttons. The questions is thus: how to add buttons that will bring the calendar to next/previous year? Please note that the new buttons need to be standard components as they need to be rendered by a particular Look & Feel manager (Insusbtantial in this case).

Many thanks

enter image description here

Answer

Radiance Wei Qi Ong picture Radiance Wei Qi Ong · Aug 29, 2013

I know this is an old question, but I finally found the answer here, from kleopatra's comment about SwingsLab demo.

The SwingsLab demo provides an example of how to set a custom calendar header on a per-component basis, but this is the code I actually used (this is global; per-application):

UIManager.put(CalendarHeaderHandler.uiControllerID, SpinningCalendarHeaderHandler.class.getName());
datePicker = new JXDatePicker();
datePicker.getMonthView().setZoomable(true); //this is needed for custom header

This seems to be experimental code (not fully public yet), so use at own risk. Hope it helps.

SwingsLab Demo