MetalThemeを変更してJInternalFrameのタイトル文字色を変更する
Total: 2015, Today: 1, Yesterday: 0
Posted by aterai at
Last-modified:
Summary
MetalThemeを変更してJInternalFrameのタイトル文字色やアクティブでない場合のタイトル文字色を変更します。
Screenshot

Advertisement
Source Code Examples
MetalLookAndFeel.setCurrentTheme(new OceanTheme() {
@Override public ColorUIResource getWindowTitleForeground() {
return new ColorUIResource(Color.RED.brighter());
}
@Override public ColorUIResource getWindowTitleInactiveForeground() {
return new ColorUIResource(Color.ORANGE.darker());
}
});
View in GitHub: Java, KotlinDescription
MetalLookAndFeel- デフォルトではタイトル文字色、非アクティブタイトル文字色ともに黒
UIManager.put("InternalFrame.activeTitleForeground", Color.RED)などでの変更は効果がないMetalTheme#getWindowTitleForeground()、MetalTheme#getWindowTitleInactiveForeground()をオーバーライドしたMetalThemeをMetalLookAndFeel.setCurrentTheme(...)メソッドで設定- このサンプルではタイトル文字色を明るい赤色、非アクティブタイトル文字色を暗いオレンジ色に変更
BasicLookAndFeel、WindowsLookAndFeel- デフォルトではタイトル文字色、非アクティブタイトル文字色ともに黒
- タイトル文字色を
UIManager.put("InternalFrame.activeTitleForeground", Color.RED)で変更可能 - 非アクティブタイトル文字色を
UIManager.put("InternalFrame.inactiveTitleForeground", Color.WHITE)で変更可能- このサンプルではタイトル文字色を赤色、非アクティブタイトル文字色を白色に変更
NimbusLookAndFeel- デフォルトではタイトル文字色は黒、非アクティブタイトル文字色は灰色
UIManager.put("InternalFrame.activeTitleForeground", Color.RED)などでの変更は効果がない- 以下のように作成した
UIDefaultsをInternalFrameTitlePaneにputClientProperty("Nimbus.Overrides", d)で設定してタイトル文字色を変更可能、非アクティブタイトル文字色は変更不可?JComponent titleBar = ((BasicInternalFrameUI) getUI()).getNorthPane(); UIDefaults d = new UIDefaults(); d.put("InternalFrame:InternalFrameTitlePane[Enabled].textForeground", Color.GREEN); // d.put("InternalFrame:InternalFrameTitlePane[Enabled+WindowNotFocused].textForeground", Color.GREEN.darker()); titleBar.putClientProperty("Nimbus.Overrides", d);