1

With the JXDayPicker it is hard to change a year, as the user has to click 12 times to achieve this. Therefor I have the same problem as Java Swing JXDatePicker.

The problem is that I want to stick with SwingX and that I need a solution which only changes one JXDatePicker.

Thus the proposed solution:

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

does not work for me. I also took a look at the MonthViewExtDemo class of the Swinglabs Demo, but I have not figured out what is going on.

Initially I thought it would be as simple as:

    JXDatePicker picker = new JXDatePicker();
    JXMonthView monthView = picker.getMonthView();
    monthView.setZoomable(true);
    SpinningCalendarHeaderHandler handler = new SpinningCalendarHeaderHandler();
    handler.install(monthView);

But apparently I was wrong.

Update: The requirements were changed a bit, such that every JXDatepicker could use the SpinningCalendarHeaderHandler, but does not have to. Therefor the proposed solution (above) can be used. I use the following in the beginning of the application:

UIManager.put(
    CalendarHeaderHandler.uiControllerID,
    "org.jdesktop.swingx.plaf.basic.SpinningCalendarHeaderHandler");
UIManager.put(
    SpinningCalendarHeaderHandler.ARROWS_SURROUND_MONTH,
    Boolean.TRUE);

And, later on, for the specific datePicker, which should use the SpinningCalendarHeaderHandler, I use:

datePicker.getMonthView().setZoomable(true);

This works for the moment, as the zoomable functionality is not implemented yet. But yeah, I think you can call this a hack.

Community
  • 1
  • 1
gillesB
  • 1,061
  • 1
  • 14
  • 30
  • 1
    interesting requirement - per-instance handlers are not supported, if I remember correctly. You might consider filing a feature request in the SwingX issue tracker, if it's halfway easy to implement you might get it in the next release :-) – kleopatra Nov 21 '13 at 15:26
  • The requirements were changed a bit, so that the new header could be used in the whole application. Therefor the isZoomable() defines if the spinning header will be used, or not. – gillesB Nov 26 '13 at 09:41

0 Answers0