你好,我正在尝试定制Nimbus中的JButton,以下是我的操作:
public static void main(String[] args)
{
// TODO Auto-generated method stub
Font police1 = new Font("Tahoma", Font.BOLD, 12);
try {
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
UIManager.setLookAndFeel(info.getClassName());
UIManager.getLookAndFeelDefaults().put("Button.background",new Color(18,55,63));
UIManager.getLookAndFeelDefaults().put("Button.font", police1);
UIManager.getLookAndFeelDefaults().put("Button.textForeground", new Color(122,216,247));
break;
}
}
} catch (Exception e) {
// If Nimbus is not available, you can set the GUI to another look and feel.
}
下面是我得到的:
您可以看到每个按钮周围都有一些灰色边框,我想要去除它或者改变它的颜色,但我找不到方法 :(。
当我按下其中一个按钮时,会得到这个:
实际上,这是距离颜色(18,55,63)最近的一个。请问是否有办法分别自定义正常外观和按下时的外观?我查阅了此链接,但对我没有帮助。