New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8289539: The color returned by CheckBox.interiorBackground is incorrect #10385
Conversation
👋 Welcome back tr! A progress list of the required criteria for merging this PR into |
|
@TejeshR13 The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
/* | ||
* @test | ||
* @bug 8289539 | ||
* @key headful |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this test marked headful to load system colors associated with the LAF?
Since we are not displaying anything on screen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I specified as headful since I'm using JFrame to subclass and change the Look and Feel at Runtime. Not sure if I can make is headless.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just because we are extending JFrame, i think there is no need to make it headful.
You can remove the @headful tag and see whether it runs in our CI systems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spent some time to check where all we are using these properties.
I see that we use "CheckBox.background" for CheckBoxIcon when it is pressed at https://github.com/openjdk/jdk/blob/master/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsIconFactory.java#L389
Can you check why we use "CheckBox.background" instead of "CheckBox.interiorBackground" in WindowsIconFactory and what is its behaviour in Windows 11?
/* | ||
* @test | ||
* @bug 8289539 | ||
* @key headful |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just because we are extending JFrame, i think there is no need to make it headful.
You can remove the @headful tag and see whether it runs in our CI systems.
@@ -657,7 +658,8 @@ protected void initComponentDefaults(UIDefaults table) | |||
new WindowsDesktopProperty("win.caret.width", null), | |||
|
|||
"CheckBox.font", ControlFont, | |||
"CheckBox.interiorBackground", WindowBackgroundColor, | |||
"CheckBox.interiorBackground", (xp != null)? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we return any color other than the default FFFFFF/null?
What is the use of "win.frame.backgroundColor" property when we always return table.get("window")?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
win.frame.backgroundColor
is key and value is color set for window
. Default color is FFFFF/null, when it is set by user the color updates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From WindowsDesktopProperty.java constructor it looks like these are not key value pairs. Similar observation is there in DesktopProperty.java.
It looks like table.get("window") is fallback when win.frame.backgroundColor is null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, but we are not modifying win.frame.backgroundColor
property, only "CheckBox.interiorBackground"
is been set to null. WindowBackgroundColor
is also used in other properties, so nothing is modified except "CheckBox.interiorBackground"
.
Here Green color is interior background and red is Background. This we can set in WindowsClassic, unlike other Look and Feel. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use GetSysColor(https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getsyscolor) to set different values for desktop properties at https://github.com/openjdk/jdk/blob/master/src/java.desktop/windows/native/libawt/windows/awt_DesktopProperties.cpp#L511
We store these values(or some default value if desktop property is null) as shown at : https://github.com/openjdk/jdk/blob/master/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java#L508
And then map them to individual UI components like checkbox: https://github.com/openjdk/jdk/blob/master/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java#L660
From https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getsyscolor we can see that some parameters are not supported in particular windows platforms.
I think we should find out whether there is any way to get proper interior background color or need to map to different Desktop color property in some platforms. If there is no way to get appropriate interior background color then we may return null after analysis. Just because we are returning null in other LAF's we should not right away return null here, it needs more analysis.
Useful link about how Windows desktop properties are mapped : https://docs.oracle.com/javase/8/docs/technotes/guides/swing/1.4/w2k_props.html
In other L&F there is no such |
From where the ImageCache knows that it needs to draw/use blue bitmap for checkbox.interiorBackground for Windows 11? |
Couldn't find the exact source, but was able to verify while debugging in |
There are multiple ImageCache/ImageBuffer pointers, Please point to github source code. I think we should find how this ImageCache knows why it should use "blue" colored bitmap and try to replicate the same for interiorBackgroundColor property. Since we don't have such property in other LAF's, we should avoid replicating same behaviour(of returning null) in Windows LAF. |
https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/classes/sun/swing/CachedPainter.java#L205 |
Lets get inputs from @prsadhuk also on this. Whether to keep checkBox.interiorBackground valid only for WindowsClassicLAF and return null for WindowsLAF Or try to find ways to return valid value for WindowsLAF. |
@TejeshR13 This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
SwingUtilities.updateComponentTreeUI(this); | ||
Color color = UIManager.getColor("CheckBox.interiorBackground"); | ||
|
||
if(laf.contains("WindowsLookAndFeel") && color != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(laf.contains("WindowsLookAndFeel") && color != null) { | |
if (laf.contains("WindowsLookAndFeel") && color != null) { |
if(laf.contains("WindowsLookAndFeel") && color != null) { | ||
throw new RuntimeException("CheckBox.interiorBackground not Null for " + | ||
laf); | ||
} else if(laf.contains("WindowsClassicLookAndFeel") && color == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} else if(laf.contains("WindowsClassicLookAndFeel") && color == null) { | |
} else if (laf.contains("WindowsClassicLookAndFeel") && color == null) { |
@TejeshR13 This pull request has been inactive for more than 8 weeks and will now be automatically closed. If you would like to continue working on this pull request in the future, feel free to reopen it! This can be done using the |
@TejeshR13 I see that this is PR is withdrawn because it was inactive. Are you working on it or is it on hold? |
I have put this on hold and will raise a new PR as the fix for this will take time. |
The color returned for
InteriorBackground
property is the default color used for only WindowsClassicLookAndFeel. For WindowsLookAndFeel theInteriorBackground
color is not been used when checkbox paint happens. In WindowsLookAndFeel the CheckBox check/uncheck is drawn usingImageCache
which is totally independent ofInteriorBackground
color in which the user expects it to be.The proposed fix is to return null for WindowsLookAndFeel (which is what happens in other LookAndFeel like Metal/Synth/Motif/Aqua ) and return default color which is the actual color used in WindowsClassicLookAndFeel.
Progress
Issue
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/10385/head:pull/10385
$ git checkout pull/10385
Update a local copy of the PR:
$ git checkout pull/10385
$ git pull https://git.openjdk.org/jdk pull/10385/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 10385
View PR using the GUI difftool:
$ git pr show -t 10385
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/10385.diff