I am building an application using the Nimbus LnF (which will be default in JSE 7). If I add any components to my application from the Jide OSS project that eventually call installJideExtension() from it updateUI method (e.g. JideTabbedPane), the menus and pop-up menus are broken. Rendering is quite off and the menu will sometimes have a grey background instead of transparent.
I discovered that the problem is that the LookAndFeelFactory is installing Jide-dependent changes to the menu look and feel based on the assumption that the Jide Action Framework is in use. Since the Jide Action Framework is not part of the open source library, this is a poor assumption.
I propose a solution to this problem.
In LookAndFeelFactory.getDefaultStyle():
- Code: Select all
public static int getDefaultStyle() {
if (_defaultStyle == -1) {
String defaultStyle = SecurityUtils.getProperty("jide.defaultStyle", "-1");
try {
_defaultStyle = Integer.parseInt(defaultStyle);
}
catch (NumberFormatException e) {
// ignore
}
if (_defaultStyle == -1) {
int suggestedStyle;
try {
if (SystemInfo.isWindowsVistaAbove() && UIManager.getLookAndFeel() instanceof WindowsLookAndFeel && SystemInfo.isJdk6Above()) {
suggestedStyle = OFFICE2007_STYLE;
}
else if (XPUtils.isXPStyleOn() && UIManager.getLookAndFeel() instanceof WindowsLookAndFeel) {
suggestedStyle = OFFICE2003_STYLE;
}
else {
suggestedStyle = VSNET_STYLE;
}
}
catch (UnsupportedOperationException e) {
suggestedStyle = VSNET_STYLE;
}
return suggestedStyle;
}
}
return _defaultStyle;
}
Change this method to use VSNET_STYLE_WITHOUT_MENU instead:
- Code: Select all
public static int getDefaultStyle() {
if (_defaultStyle == -1) {
String defaultStyle = SecurityUtils.getProperty("jide.defaultStyle", "-1");
try {
_defaultStyle = Integer.parseInt(defaultStyle);
}
catch (NumberFormatException e) {
// ignore
}
if (_defaultStyle == -1) {
int suggestedStyle;
try {
if (SystemInfo.isWindowsVistaAbove() && UIManager.getLookAndFeel() instanceof WindowsLookAndFeel && SystemInfo.isJdk6Above()) {
suggestedStyle = OFFICE2007_STYLE;
}
else if (XPUtils.isXPStyleOn() && UIManager.getLookAndFeel() instanceof WindowsLookAndFeel) {
suggestedStyle = OFFICE2003_STYLE;
}
else {
suggestedStyle = VSNET_STYLE_WITHOUT_MENU;
}
}
catch (UnsupportedOperationException e) {
suggestedStyle = VSNET_STYLE_WITHOUT_MENU;
}
return suggestedStyle;
}
}
return _defaultStyle;
}
Further, to make sure that the correct default is used for developers using the Jide Action Framework, I suggest using setDefaultStyle(LookAndFeelFactory.VSNET_STYLE) somewhere in the Action Framework's initialization code.
The result will be that the default style will not intrude on any LnF used by the application.