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 - PropSheet.setForeground does not work with Nimbus
Summary: PropSheet.setForeground does not work with Nimbus
Status: NEW
Alias: None
Product: ide
Classification: Unclassified
Component: Code (show other bugs)
Version: 8.2
Hardware: PC Windows 7
: P2 normal (vote)
Assignee: issues@ide
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-07-16 15:58 UTC by pagewidth
Modified: 2017-07-16 20:01 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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'.