我使用Nimbus外觀&感覺在我的鞦韆應用程序。Nimbus外觀和感覺刷新畫家
我設置了UIDefaults
的外觀&的主要和次要屬性的感覺。 顏色是對的。現在我遇到了問題,組件的畫家使用在更新顏色主題前定義的顏色。
有沒有辦法,更新所有組件的畫家使用新的顏色,還是我需要實現每個屬性的自定義畫家?
設置了UIDefaults
中的屬性後,我已致電SwingUtilities.updateComponentTreeUI(window)
。
編輯:
下面的代碼設置爲L & F中的整個應用程序的:
try {
for(LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
if("Nimbus".equals(info.getName())) {
UIManager.setLookAndFeel(info.getClassName());
customizeNimbusLaF();
SwingUtilities.updateComponentTreeUI(appWindow);
break;
}
}
}
catch(Exception e) {
LogUtility.warning("cannot set application look and feel");
LogUtility.warning(e.getMessage());
}
的代碼做,什麼是應該做的(設置的Nimbus外觀&感覺)。 問題是,菜單和其他組件的Painters
使用舊顏色。
以下代碼設置的顏色:
private final void customizeNimbusLaF() {
UIManager.put("control" , UIConstants.GREY_LIGHT);
UIManager.put("nimbusAlertYellow" , UIConstants.YELLOW);
UIManager.put("nimbusBase" , UIConstants.GREY_DARK);
UIManager.put("nimbusDisabledText" , UIConstants.GREY_DARK);
UIManager.put("nimbusFocus" , UIConstants.BLUE_LIGHT);
UIManager.put("nimbusGreen" , UIConstants.GREEN);
UIManager.put("nimbusInfoBlue" , UIConstants.BLUE_MIDDLE);
UIManager.put("nimbusRed", UIConstants.RED);
UIManager.put("nimbusSelectionBackground",
UIConstants.BLUE_MIDDLE);
UIManager.put("background" ,UIConstants.GREY_LIGHT);
UIManager.put("controlDkShadow" , UIConstants.GREY_DARK);
UIManager.put("controlShadow", UIConstants.GREY_MIDDLE);
UIManager.put("desktop", UIConstants.BLUE_MIDDLE);
UIManager.put("menu", UIConstants.GREY_LIGHT);
UIManager.put("nimbusBorder", UIConstants.GREY_MIDDLE);
UIManager.put("nimbusSelection", UIConstants.BLUE_MIDDLE);
UIManager.put("textBackground", UIConstants.BLUE_LIGHT);
UIManager.put("textHighlight", UIConstants.BLUE_LIGHT);
UIManager.put("textInactiveText", UIConstants.GREY_MIDDLE);
// panel
UIManager.put("Panel.background", UIConstants.GREY_LIGHT);
UIManager.put("Panel.disabled", UIConstants.GREY_LIGHT);
UIManager.put("Panel.font", UIConstants.DEFAULT_FONT);
UIManager.put("Panel.opaque", true);
// button
UIManager.put("Button.background", UIConstants.GREY_LIGHT);
UIManager.put("Button.disabled", UIConstants.GREY_LIGHT);
UIManager.put("Button.disabledText", UIConstants.BLUE_MIDDLE);
UIManager.put("Button.font", UIConstants.DEFAULT_FONT);
// menu
UIManager.put("Menu.background", UIConstants.GREY_LIGHT);
UIManager.put("Menu.disabled", UIConstants.GREY_LIGHT);
UIManager.put("Menu.disabledText", UIConstants.GREY_DARK);
UIManager.put("Menu.font", UIConstants.MENU_FONT);
UIManager.put("Menu.foreground", UIConstants.BLACK);
UIManager.put("Menu[Disabled].textForeground",
UIConstants.GREY_MIDDLE);
UIManager.put("Menu[Enabled].textForeground", UIConstants.BLACK);
UIManager.put("MenuBar.background", UIConstants.GREY_LIGHT);
UIManager.put("MenuBar.disabled", UIConstants.GREY_LIGHT);
UIManager.put("MenuBar.font", UIConstants.MENU_FONT);
UIManager.put("MenuBar:Menu[Disabled].textForeground",
UIConstants.GREY_MIDDLE);
UIManager.put("MenuBar:Menu[Enabled].textForeground",
UIConstants.BLACK);
UIManager.put("MenuItem.background", UIConstants.GREY_LIGHT);
UIManager.put("MenuItem.disabled", UIConstants.GREY_LIGHT);
UIManager.put("MenuItem.disabledText", UIConstants.GREY_MIDDLE);
UIManager.put("MenuItem.font", UIConstants.MENU_FONT);
UIManager.put("MenuItem.foreground", UIConstants.BLACK);
UIManager.put("MenuItem[Disabled].textForeground",
UIConstants.GREY_MIDDLE);
UIManager.put("MenuItem[Enabled].textForeground",
UIConstants.BLACK);
// tree
UIManager.put("Tree.background", UIConstants.BLACK);
}
在UIConstants
的常數的數據類型是任一類型的Font
取決於屬性的Color
進行設置。
有人能告訴我我的問題在哪裏嗎?
電賀 邁克爾
''''SSCCE'的哪一部分你不明白???,erghttt !!!,'2.'然後最好使用'SeaGlass'或另一個基於Nimbus的'L&F','3。你在所有使用'背景'的情況下重新設置了'Painter'或「畫家」畫的價值,必須決定背景或畫家 – mKorbel
,爲什麼你忽略了@aephyr的代碼庫,我們知道的關於Nimbus及其主題的所有好處...... – mKorbel