我正在使用Nimbus外观, 我知道如何通过使用以下代码更改工具提示颜色:
UIManager.put("info", Color.white);
但是如何更改图标(最小化,最大化和关闭)到另一个图标/ png文件?
以下是关闭按钮的键:InternalFrame:InternalFrameTitlePane:"InternalFrameTitlePane.closeButton"[Enabled].backgroundPainter
与那里的info
相同。
以下是包含所有密钥的网站:http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/_nimbusDefaults.html#primary
答案 0 :(得分:2)
看起来像一个丑陋的哈克,但对我有用。
JComponent title = ((BasicInternalFrameUI)myInternalFrame.getUI()).getNorthPane();
for (int i = 0; i < title.getComponentCount(); i++) {
JComponent component = (JComponent)title.getComponent(i);
if(component instanceof JButton) {
JButton button = ((JButton)component);
if(button.getName() == null) continue;
if(button.getName().endsWith("closeButton")) {
button.setIcon(myIcon);
button.setSelectedIcon(myIcon);
button.setPressedIcon(myIcon);
}
if(button.getName().endsWith("maximizeButton")) {
...
}
if(button.getName().endsWith("iconifyButton")) {
...
}
}
}