Skip to main content

JXDatePicker -- change the format of the current day text

Please note these forums are being decommissioned and use the new and improved forums at
3 replies [Last post]
Joined: 2012-03-12
Points: 0


I am new to JXDatePicker, and wonder if there is a setting to change the text at the bottom of the month viewer that says "Today is 12 March 2012" or whatever today's date happens to be. I'd like to be able to set the format to be MMM dd yyyy. Or can that display be suppressed?

Thanks in advance for any help anyone can provide.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2003-06-12
Points: 0

Here is an example of what I use, and here I removed that Today string while adjusting a lot of other stuff (I Like my calendars plain and small ;-) :

The code that remove the Today is "dp.getLinkPanel().setVisible(false);"

<p>private static JXDatePicker makeStandardDatePicker(DateFormat format, long millis) {<br />
        Color colorTextText = UIManager.getColor("textText");<br />
        if (colorTextText == null) {<br />
            colorTextText = Color.BLACK;<br />
<p>        Color colorTFBack = UIManager.getColor("TextField.background");</p>
<p>        UIManager.put("JXMonthView.boxPaddingX", 1);<br />
        UIManager.put("JXMonthView.boxPaddingY", 1);<br />
        UIManager.put("JXMonthView.background", new ColorUIResource(colorTFBack));<br />
        UIManager.put("JXMonthView.monthStringBackground", UIManager.getColor("Button.background"));<br />
        UIManager.put("JXMonthView.monthStringForeground", new ColorUIResource(colorTextText));<br />
        UIManager.put("JXMonthView.daysOfTheWeekForeground", new ColorUIResource(colorTextText));<br />
        UIManager.put("JXMonthView.weekOfTheYearForeground", UIManager.getColor("Button.background"));<br />
        UIManager.put("JXMonthView.unselectableDayForeground", new ColorUIResource(Color.LIGHT_GRAY));<br />
        //UIManager.put("JXMonthView.selectedBackground", new ColorUIResource(197, 220, 240));<br />
        UIManager.put("JXMonthView.flaggedDayForeground", new ColorUIResource(Color.BLUE));<br />
        UIManager.put("JXMonthView.leadingDayForeground", new ColorUIResource(Color.GRAY));<br />
        UIManager.put("JXMonthView.trailingDayForeground", new ColorUIResource(Color.GRAY));<br />
        UIManager.put("JXMonthView.font", new FontUIResource("SansSerif", Font.PLAIN, 11));<br />
        UIManager.put("JXMonthView.monthDownFileName", makeLazyIcon("/com/application/resources/16/prev.png"));<br />
        UIManager.put("JXMonthView.monthUpFileName", makeLazyIcon("/com/application/resources/16/next.png"));<br />
        UIManager.put("JXDatePicker.numColumns", FORMAT_DATE.length() + 1);<br />
        UIManager.put("JXDatePicker.arrowIcon", makeLazyIcon("/com/application/resources/16/down.png"));</p>
<p>        JXDatePicker dp = new JXDatePicker();</p>
<p>        dp.getLinkPanel().setVisible(false);<br />
        dp.setFormats(format);<br />
<p>        if (millis > 0) {<br />
            dp.setDate(new Date(millis));<br />
<p>        JXMonthView mv = dp.getMonthView();</p>
<p>        mv.setSelectionMode(SelectionMode.SINGLE_SELECTION);<br />
        mv.setFirstDayOfWeek(Calendar.SUNDAY);<br />
        mv.setShowingWeekNumber(false);<br />
        mv.setShowingLeadingDays(true);<br />
        mv.setShowingTrailingDays(true);<br />
        mv.setTodayBackground(Color.YELLOW);<br />
<p>        return dp;<br />

Joined: 2003-06-12
Points: 0

Sorry for the mess, but this forum software is a @*#& joke...

Joined: 2003-06-11
Points: 0

good question (read: the api is a murky in that respect ;-)

what you are probably looking for is the linkFormat property on the JXDatePicker: that's a String which defines a MessageFormat used for formatting the linkDay in the LinkPanel (the part that appears in the JXMonthView popup below the monthView). It's set application-wide in the UIManager with key  "JXDatePicker.linkFormat".

So, if you want to change it for all your pickers, simply configure that early in the app.