如何设置按钮上的文本颜色。我已经尝试过了,但它不起作用。
JButton button1 = new JButton();
button1.setForeground(Color.RED);
button1.setText("Close");
button1.setEnabled(false);
颜色保持黑色。
最佳答案
is it possible to change the color when the button is disabled
您可以使用 UIManager 来实现此目的。请参阅UIManager Defaults了解更多信息。
如果您可以使用 UIManager,那么您将需要创建自定义 UI。
关于java - 如何设置按钮上的文字颜色? java ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21800543/