0

I'm working on JXdatepicker and i can't modify the red color of unselectable dates,

I found a subject about it, but it doesn't working "setting the following UIDefaults property JXMonthView.unselectableDayForeground

any help please,

KF2
  • 9,887
  • 8
  • 44
  • 77
  • JXDatePicker docs at http://www.jdocs.com/swingx/1.0/org/jdesktop/swingx/JXDatePicker.html – emecas Apr 10 '13 at 13:28
  • hmm ... worksforme, assuming you want to change the color of the cross in the montView and it's set before creating the datepicker. Which swingx version do you have? – kleopatra Apr 10 '13 at 14:02
  • 1.6.1 ! i used this instruction to solve it, but it does'nt work too : UIManager.put("JXMontView.unselectableDayForeground", new ColorUIResource(Color.GREEN)); – slov abd Apr 10 '13 at 19:41
  • Thanks a lot !! i tried to set the color after creating datepicker ! it must be setting before instanciate jxdatepicker ! – slov abd Apr 10 '13 at 19:57
  • i have a second problem with this component, when i added JXdatpicker to my applet, there is a warnning ( small icon ) showed when i display it, "java applet window", it can be associated to the version of swingx ? i'm using jre 6 & swing 1.6.1 – slov abd Apr 10 '13 at 20:36

1 Answers1

0

since i am in hurry to answer this

but you can use the swingx source code from here https://github.com/cuba-platform/swingx-core/tree/master/src/main/java/org/jdesktop/swingx

then go to the function initMonthview in JXDatepicker.java overwrite it with this one Color.Black you can use your own color. This fix the problem when you have a plaf with the jlabel text color as white and it hides with the background color of JXdatepicker.

 private void initMonthView() {
        _monthView = new JXMonthView();
//        _monthView.setSelectionModel(new SingleDaySelectionModel());
        _monthView.setTraversable(true);
        _monthView.addPropertyChangeListener(getMonthViewListener());
        _monthView.setDayForeground(Calendar.SUNDAY, Color.black);
        _monthView.setDayForeground(Calendar.MONDAY, Color.black);
        _monthView.setDayForeground(Calendar.TUESDAY, Color.black);
        _monthView.setDayForeground(Calendar.WEDNESDAY, Color.black);
        _monthView.setDayForeground(Calendar.THURSDAY, Color.black);
        _monthView.setDayForeground(Calendar.FRIDAY, Color.black);
        _monthView.setDayForeground(Calendar.SATURDAY, Color.black);

    }

and then set the color you like then export it as a jar have fun.

or rather you can do a hard job of pluggable Look and Feel.

alternatively you can create a new constructor in the JXDatepicker.java which takes the object of JXMonthview with the particular set of colors

means create a object of

_monthView = new JXMonthView();
//        _monthView.setSelectionModel(new SingleDaySelectionModel());
         _monthView.setTraversable(true);
        _monthView.addPropertyChangeListener(getMonthViewListener());
        _monthView.setDayForeground(Calendar.SUNDAY, Color.black);
        _monthView.setDayForeground(Calendar.MONDAY, Color.black);
        _monthView.setDayForeground(Calendar.TUESDAY, Color.black);
        _monthView.setDayForeground(Calendar.WEDNESDAY, Color.black);
        _monthView.setDayForeground(Calendar.THURSDAY, Color.black);
        _monthView.setDayForeground(Calendar.FRIDAY, Color.black);
        _monthView.setDayForeground(Calendar.SATURDAY, Color.black);

now add

create a new constructor like

JXDatepicker(JXMonthView temp){
_monthview = temp;
 JXDatepicker();

}

export it as jar use it.

Killerbeans
  • 1,903
  • 2
  • 10
  • 7