Skip to content

Commit 0e523f1

Browse files
committed
SwingX: fixed missing highlighting of "today" in JXMonthView and JXDatePicker
1 parent 9041a16 commit 0e523f1

7 files changed

Lines changed: 17 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ FlatLaf Change Log
2727
- Fixed possible exception in `FlatUIUtils.resetRenderingHints()`. (issue #575)
2828
- Fixed AWT components on macOS, which use Swing components internally. (issue
2929
#583)
30+
- SwingX: Fixed missing highlighting of "today" in `JXMonthView` and
31+
`JXDatePicker`.
3032

3133

3234
## 2.4

flatlaf-swingx/src/main/java/com/formdev/flatlaf/swingx/ui/FlatMonthViewUI.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616

1717
package com.formdev.flatlaf.swingx.ui;
1818

19+
import java.awt.Color;
1920
import java.awt.Insets;
2021
import java.util.Calendar;
2122
import javax.swing.JComponent;
23+
import javax.swing.UIManager;
2224
import javax.swing.border.Border;
2325
import javax.swing.border.CompoundBorder;
2426
import javax.swing.border.EmptyBorder;
@@ -52,6 +54,8 @@ protected CalendarRenderingHandler createRenderingHandler() {
5254
private static class FlatRenderingHandler
5355
extends RenderingHandler
5456
{
57+
private final Color todayColor = UIManager.getColor( "JXMonthView.todayColor" );
58+
5559
@Override
5660
public JComponent prepareRenderingComponent( JXMonthView monthView, Calendar calendar,
5761
CalendarState dayState )
@@ -67,8 +71,12 @@ public JComponent prepareRenderingComponent( JXMonthView monthView, Calendar cal
6771
Border b = c.getBorder();
6872
if( b instanceof CompoundBorder && ((CompoundBorder)b).getInsideBorder() instanceof EmptyBorder )
6973
border = new CompoundBorder( ((CompoundBorder)b).getOutsideBorder(), new FlatEmptyBorder( py * 2, 0, py * 2, 0 ) );
70-
} else if( dayState == CalendarState.TODAY )
71-
border = new FlatLineBorder( new Insets( py, px, py, px ), monthView.getTodayBackground() );
74+
} else if( dayState == CalendarState.TODAY ) {
75+
Color lineColor = monthView.getTodayBackground();
76+
if( lineColor == null )
77+
lineColor = todayColor;
78+
border = new FlatLineBorder( new Insets( py, px, py, px ), lineColor );
79+
}
7280

7381
if( border == null )
7482
border = new FlatEmptyBorder( py, px, py, px );

flatlaf-swingx/src/main/resources/com/formdev/flatlaf/swingx/FlatLaf.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ JXDatePicker.border = com.formdev.flatlaf.swingx.ui.FlatDatePickerBorder
3939

4040
JXMonthView.monthDownFileName = {icon}com.formdev.flatlaf.swingx.ui.FlatMonthDownIcon
4141
JXMonthView.monthUpFileName = {icon}com.formdev.flatlaf.swingx.ui.FlatMonthUpIcon
42+
JXMonthView.todayColor = @foreground
4243

4344

4445
#---- TitledPanel ----

flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ JXMonthView.monthStringBackground #4c5052 HSL 200 4 31 javax.swing.plaf.C
445445
JXMonthView.monthStringForeground #bbbbbb HSL 0 0 73 javax.swing.plaf.ColorUIResource [UI]
446446
JXMonthView.monthUpFileName [lazy] 20,20 com.formdev.flatlaf.swingx.ui.FlatMonthUpIcon [UI]
447447
JXMonthView.selectedBackground #4b6eaf HSL 219 40 49 javax.swing.plaf.ColorUIResource [UI]
448+
JXMonthView.todayColor #bbbbbb HSL 0 0 73 javax.swing.plaf.ColorUIResource [UI]
448449
JXMonthView.trailingDayForeground #8c8c8c HSL 0 0 55 javax.swing.plaf.ColorUIResource [UI]
449450
JXMonthView.unselectableDayForeground #e05555 HSL 0 69 61 javax.swing.plaf.ColorUIResource [UI]
450451
JXMonthView.weekOfTheYearForeground #888888 HSL 0 0 53 javax.swing.plaf.ColorUIResource [UI]

flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@ JXMonthView.monthStringBackground #dfdfdf HSL 0 0 87 javax.swing.plaf.C
450450
JXMonthView.monthStringForeground #000000 HSL 0 0 0 javax.swing.plaf.ColorUIResource [UI]
451451
JXMonthView.monthUpFileName [lazy] 20,20 com.formdev.flatlaf.swingx.ui.FlatMonthUpIcon [UI]
452452
JXMonthView.selectedBackground #bfdaf2 HSL 208 66 85 javax.swing.plaf.ColorUIResource [UI]
453+
JXMonthView.todayColor #000000 HSL 0 0 0 javax.swing.plaf.ColorUIResource [UI]
453454
JXMonthView.trailingDayForeground #8c8c8c HSL 0 0 55 javax.swing.plaf.ColorUIResource [UI]
454455
JXMonthView.unselectableDayForeground #e02222 HSL 0 75 51 javax.swing.plaf.ColorUIResource [UI]
455456
JXMonthView.weekOfTheYearForeground #666666 HSL 0 0 40 javax.swing.plaf.ColorUIResource [UI]

flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@ JXMonthView.monthStringBackground #00ff00 HSL 120 100 50 javax.swing.plaf.C
466466
JXMonthView.monthStringForeground #0000ff HSL 240 100 50 javax.swing.plaf.ColorUIResource [UI]
467467
JXMonthView.monthUpFileName [lazy] 20,20 com.formdev.flatlaf.swingx.ui.FlatMonthUpIcon [UI]
468468
JXMonthView.selectedBackground #aaffaa HSL 120 100 83 javax.swing.plaf.ColorUIResource [UI]
469+
JXMonthView.todayColor #ff0000 HSL 0 100 50 javax.swing.plaf.ColorUIResource [UI]
469470
JXMonthView.trailingDayForeground #c0c0c0 HSL 0 0 75 javax.swing.plaf.ColorUIResource [UI]
470471
JXMonthView.unselectableDayForeground #0000ff HSL 240 100 50 javax.swing.plaf.ColorUIResource [UI]
471472
JXMonthView.weekOfTheYearForeground #0000ff HSL 240 100 50 javax.swing.plaf.ColorUIResource [UI]

flatlaf-theme-editor/src/main/resources/com/formdev/flatlaf/themeeditor/FlatLafUIKeys.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ JXMonthView.monthStringBackground
368368
JXMonthView.monthStringForeground
369369
JXMonthView.monthUpFileName
370370
JXMonthView.selectedBackground
371+
JXMonthView.todayColor
371372
JXMonthView.trailingDayForeground
372373
JXMonthView.unselectableDayForeground
373374
JXMonthView.weekOfTheYearForeground

0 commit comments

Comments
 (0)