如何在 JButton 中设置文本颜色?

How to set text color in JButton?

有人知道如何在JButton中设置部分文字颜色吗?

例如:

我的按钮有文本:"I Love YOU."

现在,我只想用 RED 颜色绘制单词“Love”,以及单词 "I" & "You" 黑色。

我应该怎么做?

您可以使用 HTML

new JButton("<html><center>I "
                 + "<font color=red>Love</font>"+"You</center></html>");