This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 271105

Summary: PropSheet.setForeground does not work with Nimbus
Product: ide Reporter: pagewidth
Component: CodeAssignee: issues@ide <issues>
Status: NEW ---    
Severity: normal    
Priority: P2    
Version: 8.2   
Hardware: PC   
OS: Windows 7   
Issue Type: DEFECT Exception Reporter:

Description pagewidth 2017-07-16 15:58:52 UTC
According to the documentation, PropSheet.setForeground sets the foreground color of property sheets expandable sets in the Properties window.  However, this UIManager setting is overriden when using Nimbus L&F.

Here is an except of the code in org.openide.explorer.propertysheet.PropUtils.java:

setForegroundColor = UIManager.getColor(KEY_SETFG);

        if( nimbus || gtk )
            setForegroundColor = new Color( UIManager.getColor( "Menu.foreground" ).getRGB() ); //NOI18N

        if (setForegroundColor == null) {
            setForegroundColor = UIManager.getColor("Table.foreground"); //NOI18N

            if (setForegroundColor == null) {
                setForegroundColor = UIManager.getColor("textText");

                if (setForegroundColor == null) {
                    setForegroundColor = Color.BLACK;
                }
            }
        }

The condition for nimbus should first check if setForegroundColor is null, and if so, then check for Nimbus.  The corrected condition statement should read:

 if( setForegroundColor == null && (nimbus || gtk) )
            setForegroundColor = new Color( UIManager.getColor( "Menu.foreground" ).getRGB() ); //NOI18N


The same fix applies to PropSheet.setBackground and PropSheet.selectedSetBackground.  An except of the code from PropUtils.java for these settings:

setRendererColor = UIManager.getColor(KEY_SETBG); //NOI18N
        selectedSetRendererColor = UIManager.getColor(KEY_SELSETBG); //NOI18N

        if( nimbus || gtk ) {
            setRendererColor = UIManager.getColor( "Menu.background" );//NOI18N
            selectedSetRendererColor = UIManager.getColor("Tree.selectionBackground"); //NOI18N
        }


The corrected condition statement should be separated and first check if setRendererColor and selectedSetRendererColor are null:

if( setRendererColor == null && (nimbus || gtk) ) {
            setRendererColor = UIManager.getColor( "Menu.background" );//NOI18N
        }

if( selectedSetRendererColor == null && (nimbus || gtk) ) {
            selectedSetRendererColor = UIManager.getColor("Tree.selectionBackground"); //NOI18N
        }


As an aside, PropSheet.selectedSetForeground and Tree.altbackground do not check for Nimbus at all.  Is the Nimbus condition really necessary?  Are the default settings sufficient?
Comment 1 pagewidth 2017-07-16 20:01:20 UTC
The word "except" should be "excerpt", as in 'excerpt of the source code'.