有没有办法在 jDatePicker 上更改按钮颜色

时间:2021-04-16 16:52:41

标签: java

我想更改 jDatePicker 的按钮颜色,但不知道如何更改。

public JDatePickerImpl dateSelector()
{
    UtilDateModel model = new UtilDateModel();
    Properties p = new Properties();
    p.put("text.today", "Today");
    p.put("text.month", "Month");
    p.put("text.year", "Year");
    JDatePanelImpl datePanel = new JDatePanelImpl(model, p);
    datePanel.setBackground(Color.decode("#00387b"));
    datePanel.setForeground(Color.decode("#00387b"));
    JDatePickerImpl datePicker = new JDatePickerImpl(datePanel, new DateLabelFormatter());
    datePicker.setBackground(Color.decode("#00387b"));
    datePicker.setForeground(Color.decode("#00387b"));
    return datePicker;
}

setBackground() 似乎只是在按钮旁边添加了一条小色带,而 setForeground 完全没有任何作用。组合框的 Syme。 感谢您的帮助

1 个答案:

答案 0 :(得分:0)

也许您需要将文本的背景设置为。也许使用javafx更容易。

相关问题