您好,我正在尝试从 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.
}
这就是我得到的:
如您所见,每个按钮周围都有某种灰色边框,我正在尝试将其删除或更改其颜色,但我找不到方法:(。
一旦我按下它们,我就会得到这个:
这实际上是最接近 Color(18,55,63) 的那个。请问有没有办法分别自定义正常外观和压制外观?我检查了这个链接http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/_nimbusDefaults.html但它帮不了我。