mirror of
https://gitlab.com/Monsterovich/lanemu.git
synced 2024-07-07 06:01:16 +02:00
Added theme fix to calendar
This commit is contained in:
parent
5b021b6997
commit
0e48a87cea
|
@ -18,6 +18,8 @@
|
||||||
*/
|
*/
|
||||||
package org.p2pvpn.gui;
|
package org.p2pvpn.gui;
|
||||||
import com.github.lgooddatepicker.components.CalendarPanel;
|
import com.github.lgooddatepicker.components.CalendarPanel;
|
||||||
|
import com.github.lgooddatepicker.components.DatePickerSettings;
|
||||||
|
import com.github.lgooddatepicker.components.DatePickerSettings.DateArea;
|
||||||
import com.github.lgooddatepicker.zinternaltools.CustomPopup;
|
import com.github.lgooddatepicker.zinternaltools.CustomPopup;
|
||||||
import com.github.lgooddatepicker.zinternaltools.CalendarSelectionEvent;
|
import com.github.lgooddatepicker.zinternaltools.CalendarSelectionEvent;
|
||||||
import com.github.lgooddatepicker.zinternaltools.YearMonthChangeEvent;
|
import com.github.lgooddatepicker.zinternaltools.YearMonthChangeEvent;
|
||||||
|
@ -30,6 +32,7 @@ import java.time.ZoneId;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import javax.swing.JSpinner;
|
import javax.swing.JSpinner;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
|
import javax.swing.UIManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calendar widget for the date entry field in InviteWindow.
|
* Calendar widget for the date entry field in InviteWindow.
|
||||||
|
@ -47,10 +50,13 @@ public class CalendarPopup implements CalendarListener {
|
||||||
inputField = field;
|
inputField = field;
|
||||||
|
|
||||||
calendarPanel = new CalendarPanel();
|
calendarPanel = new CalendarPanel();
|
||||||
|
DatePickerSettings settings = new DatePickerSettings();
|
||||||
|
applyTheme(settings);
|
||||||
|
calendarPanel.setSettings(settings);
|
||||||
calendarPanel.addCalendarListener(this);
|
calendarPanel.addCalendarListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void show() {
|
public void show() {
|
||||||
Date originalDate = (Date) inputField.getModel().getValue();
|
Date originalDate = (Date) inputField.getModel().getValue();
|
||||||
calendarPanel.setSelectedDate(originalDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate());
|
calendarPanel.setSelectedDate(originalDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate());
|
||||||
|
|
||||||
|
@ -68,6 +74,24 @@ public class CalendarPopup implements CalendarListener {
|
||||||
calendarPopup.show();
|
calendarPopup.show();
|
||||||
calendarPanel.requestFocus();
|
calendarPanel.requestFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fixme: remove this function when this is fixed
|
||||||
|
// https://github.com/LGoodDatePicker/LGoodDatePicker/issues/195
|
||||||
|
private void applyTheme(DatePickerSettings settings) {
|
||||||
|
settings.setColor(DateArea.CalendarBackgroundNormalDates, UIManager.getColor("Panel.background"));
|
||||||
|
settings.setColor(DateArea.BackgroundOverallCalendarPanel, UIManager.getColor("Panel.background"));
|
||||||
|
settings.setColor(DateArea.TextFieldBackgroundValidDate, UIManager.getColor("TextField.background"));
|
||||||
|
settings.setColor(DateArea.CalendarBackgroundSelectedDate, UIManager.getColor("Table.selectionBackground"));
|
||||||
|
settings.setColor(DateArea.BackgroundTopLeftLabelAboveWeekNumbers, UIManager.getColor("Label.background"));
|
||||||
|
settings.setColor(DateArea.BackgroundMonthAndYearMenuLabels, UIManager.getColor("Label.background"));
|
||||||
|
settings.setColor(DateArea.BackgroundTodayLabel, UIManager.getColor("Label.background"));
|
||||||
|
settings.setColor(DateArea.BackgroundClearLabel, UIManager.getColor("Button.background"));
|
||||||
|
settings.setColor(DateArea.CalendarTextNormalDates, UIManager.getColor("Label.foreground"));
|
||||||
|
settings.setColor(DateArea.CalendarBorderSelectedDate, UIManager.getColor("Table.selectionBackground").darker());
|
||||||
|
settings.setColor(DateArea.BackgroundCalendarPanelLabelsOnHover, UIManager.getColor("ComboBox.buttonHighlight"));
|
||||||
|
settings.setColor(DateArea.CalendarTextWeekdays, UIManager.getColor("Button.foreground"));
|
||||||
|
settings.setColorBackgroundWeekdayLabels(UIManager.getColor("Button.background"), true);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void selectedDateChanged(CalendarSelectionEvent event) {
|
public void selectedDateChanged(CalendarSelectionEvent event) {
|
||||||
|
|
Loading…
Reference in a new issue