-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
JDK-8016524: [macosx] Bottom line is not visible for JTableHeader #7219
Conversation
Hi @honkar-jdk, welcome to this OpenJDK project and thanks for contributing! We do not recognize you as Contributor and need to ensure you have signed the Oracle Contributor Agreement (OCA). If you have not signed the OCA, please follow the instructions. Please fill in your GitHub username in the "Username" field of the application. Once you have signed the OCA, please let us know by writing If you already are an OpenJDK Author, Committer or Reviewer, please click here to open a new issue so that we can record that fact. Please use "Add GitHub user honkar-jdk" as summary for the issue. If you are contributing this work on behalf of your employer and your employer has signed the OCA, please let us know by writing |
@honkar-jdk 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. |
/covered |
Thank you! Please allow for a few business days to verify that your employer has signed the OCA. Also, please note that pull requests that are pending an OCA check will not usually be evaluated, so your patience is appreciated! |
src/java.desktop/macosx/classes/com/apple/laf/AquaTableHeaderBorder.java
Outdated
Show resolved
Hide resolved
Webrevs
|
@prsadhuk please review |
{ | ||
throw new RuntimeException(e); | ||
} | ||
frame.dispose(); |
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.
frame should be disposed irrespective of whether it fails or pass.
Also, it should be under EDT too.
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.
The test is not marked for mac only and I see it fails in my ubuntu locally.
Did you try running the test in CI system?
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.
@prsadhuk I have changed the test case to explicitly set the table and header background to white. Mach5 tests are passing on all platforms including linux now. Can you please let me know in case you are seeing any issues on Ubuntu locally, with the new test case?
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.
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.
It seems there's a anomaly for JTableHeader border in native and jdk in Windows L&F..
The system table shows here doesn't show any line
whereas in our SwingSet2 we have a light grey line
Technically, it might be construed as a bug but I guess I will prefer a demarcation line between header and body.
It's upto you if you want to take a look at this in a separate issue or in this.
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.
@prsadhuk Thank you for looking into it. I think this fix will require a change in Window related L&F classes. I think it would help me if I track this as separate issue.
// if pixel color is white then border not visible, throw Exception | ||
if(lowerLeft.getRGB() == WHITE_RGB || lowerRight.getRGB() == WHITE_RGB) | ||
{ | ||
throw new RuntimeException("JTableHeader Bottom Border not visible"); |
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.
Not sure this check is correct. If we have dark theme or the background is changed in system, then I guess the test will fail even with fix. Maybe you can set the JTable background to white explicitly.
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.
@prsadhuk I have explicitly set the background to white for the table as well as the header.
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.
@prsadhuk The fix and test case is ready for review. I have marked the testcase as mac-only.
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.
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 got the 2nd part of the question myself which is because of white gridlines used in AquaLookAndFeel so invisible..
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.
@prsadhuk It passes in my local (mac 11.6.2) and in CI systems as well. Are there any system specific configurations that I need to look into to fix this issue?
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.
@prsadhuk Ready for review. Changed the test case to paint JFrame to BufferedImage. The test case is marked headful though robot calls are not used, as the JFrame rendering requires it to be 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.
I believe you could raise a awt Robot issue for not getting correct pixel color via getPixelColor(x,y) on retina display (if you are sure JDK-8274939 patch didn't help)
@@ -105,7 +105,7 @@ public void paintBorder(final Component c, final Graphics g, final int x, final | |||
final int newWidth = width; | |||
final int newHeight = height; | |||
|
|||
painter.paint(g, c, newX - 1, newY - 1, newWidth + 1, newHeight); | |||
painter.paint(g, c, newX - 1, newY - 1, newWidth + 1, newHeight + 1); |
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 would like to clarify the change here, what is the coordinates/size passed here is it a size of the component+border, or just a size of the component? So if decrease the newX/Y will we draw in the component area, or accidentally draw outside?
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.
@mrserb It is the size of component + border. The component being painted here is DefaultTableCellHeaderRenderer
.
Tested under two cases
- Decreasing x & y, keeping width & height same as above - Border gets drawn inside the component area making header look smaller.
- Decreasing width & height, keeping x & y same - Border is not visible
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 it is a size of the component+border then how we can draw outside of it by decreasing the x/y?
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.
@mrserb Sorry, what I meant to convey is that the coordinate arguments sent to painter.paint() is including the component + border, and newX, newY, newHeight, newWidth are coordinates of component only.
So when newX and newY are decreased by more than 1 in paint() method, border seems to be drawn inside the component area and not outside (in this case within the table header)
test/jdk/javax/swing/JTableHeader/8016524/JTHeaderBorderTest.java
Outdated
Show resolved
Hide resolved
String tableColor = Integer.toHexString(table.getBackground().getRGB()); | ||
String headerColor = Integer.toHexString(table.getTableHeader().getBackground().getRGB()); | ||
String pixelColor = tableColor; | ||
boolean isBottomLineVisible = false; |
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.
To nitpick, I will much rather use Color instead of converting to String as we are trying to check and compare for Color but it's not a dealbreaker.
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.
@prsadhuk BufferedImage's getRGB() method returns a int value and does not have equivalent method that returns a Color object (at specified coordinates), I was able to change string comparisons to int. Please let me know if this should be okay?
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.
You could have used getBackground() itself to get a Color object but amnot finicky about it, its upto you.
boolean isBottomLineVisible = false; | ||
|
||
// scan table header region to check if bottom border of JTableHeader is visible | ||
for (int y = Y_OFFSET; y <= Y_OFFSET+25; y++) { |
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.
Can't we use X_OFFSET for hardcoded 25 here?
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.
The X_OFFSET is different from the 25 specified in the loop, this specifies the vertical scan range. To avoid confusion I have changed it as Y_OFFSET_START and Y_OFFSET_END.
@honkar-jdk This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 259 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@prsadhuk, @prrace) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
/integrate |
@honkar-jdk |
/sponsor |
Going to push as commit f33329e.
Your commit was automatically rebased without conflicts. |
@prsadhuk @honkar-jdk Pushed as commit f33329e. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Previously, the JTableHeader Bottom line wasn't visible on MacOS LAF (Aqua). With the fix the bottom line (light grey) is visible.
Changes were made to AquaTableHeaderBorder.paintBorder method and the height of the component+border was adjusted in paint method.
A new test case (JTHeaderBorderTest.java) was added to test the fix as there was no corresponding test case present for this issue previously. The test checks if the border is visible by checking the color at the border location with the background color of the table and table-header, if both are different test case passes and it fails if the pixel color at border location matches either the table-header or table background color.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/7219/head:pull/7219
$ git checkout pull/7219
Update a local copy of the PR:
$ git checkout pull/7219
$ git pull https://git.openjdk.java.net/jdk pull/7219/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 7219
View PR using the GUI difftool:
$ git pr show -t 7219
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/7219.diff