Skip to content

Conversation

@prsadhuk
Copy link
Contributor

@prsadhuk prsadhuk commented Oct 24, 2025

Icon rendering offset is wrong for RTL orientation which is why the icon was not rendered properly..Also, LEADING horizontal text position was not accounted for..

Before fix

image

With fix

image

Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8370465: Right to Left Orientation Issues with MenuItem Component (Bug - P3)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/27968/head:pull/27968
$ git checkout pull/27968

Update a local copy of the PR:
$ git checkout pull/27968
$ git pull https://git.openjdk.org/jdk.git pull/27968/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 27968

View PR using the GUI difftool:
$ git pr show -t 27968

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/27968.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 24, 2025

👋 Welcome back psadhukhan! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Oct 24, 2025

@prsadhuk 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:

8370465: Right to Left Orientation Issues with MenuItem Component

Reviewed-by: kizune, honkar

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 121 new commits pushed to the master branch:

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.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk
Copy link

openjdk bot commented Oct 24, 2025

@prsadhuk The following label will be automatically applied to this pull request:

  • client

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.

@prsadhuk
Copy link
Contributor Author

/touch

@openjdk
Copy link

openjdk bot commented Oct 24, 2025

@prsadhuk The pull request is being re-evaluated and the inactivity timeout has been reset.

@openjdk openjdk bot added the rfr Pull request is ready for review label Oct 24, 2025
@mlbridge
Copy link

mlbridge bot commented Oct 24, 2025

Webrevs

@TejeshR13
Copy link
Contributor

image

With fix, starting position of text and icon seems to be having an offset compared to metal. Icon is starting a bit right side (2nd line) and text is a bit left side.

@prsadhuk
Copy link
Contributor Author

prsadhuk commented Oct 28, 2025

That is expected as for WIndows L&F we are having dedicated offset for icon and checkmark/bullet so that they dont overlap as earlier before JDK-8348760 the icon and radiobutton bullet/checkmark was overlapping so checkmark was not visible so now each is drawn on its own dedicated position

if (icon != null) {
icon.paintIcon(c, g, x + VistaMenuItemCheckIconFactory.getIconWidth(),
y + OFFSET);
if (!c.getComponentOrientation().equals(ComponentOrientation.RIGHT_TO_LEFT)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just if(c.getComponentOrientation().isLeftToRight()) ? Then you will not need the extra import and the documentation for ComponentOrientation clearly says that direct comparison should be avoided.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I have modified to use the existing LTR check already used in the file

Rectangle rect = lr.getTextRect();

rect.x += lh.getAfterCheckIconGap();
if (menuItem.getHorizontalTextPosition() != SwingConstants.LEADING) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure i understand why we only checking for "LEADING" text position. What if it is specified specifically as "LEFT" or "RIGHT"? What would result look like in the different component orientations with this fix?

Copy link
Contributor Author

@prsadhuk prsadhuk Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LEADING causes the text to appear before icon so need to account for it..

Before fix

Image

After fix

Image

Others are working as I can see "horizontalAlignment = LEFT..." and "horizontalAlignment=RIGHT" which uses LEFT and RIGHT horizontal text positioning

image

Copy link
Contributor Author

@prsadhuk prsadhuk Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I have modified the PR to rectify layouting ensuring radiobutton bullet/checkmark are drawn at dedicated position and doesn't interfere with icon position for RTL too..Previous PR iteration was not taking into account of this for RTL so if the menuitem was selected in RTL, it was not shown..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tested the latest version of the fix with the slightly modified test case (i added two extra menu items with
menuItem.setHorizontalTextPosition(SwingConstants.LEFT);
and
menuItem.setHorizontalTextPosition(SwingConstants.RIGHT);
and it does not look exactly correct. Here's the screenshot:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed..it now looks ok to me...Please check

image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, new version works correctly. I would suggest to add these menu items to the regression test but that is optional.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @azuev-java suggested, it might be a good idea to add the extra cases to the test.

Copy link
Contributor Author

@prsadhuk prsadhuk Oct 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the menu items
@azuev-java Please take a look

@prsadhuk prsadhuk changed the title 8370465: Right to Left Orientation Issues with MenuItem Component. 8370465: Right to Left Orientation Issues with MenuItem Component Oct 29, 2025
@honkar-jdk
Copy link
Contributor

honkar-jdk commented Oct 29, 2025

There seems to be less gap between text and icon in RTL Windows L&F case. The icon border looks different when the icon is to the left and right side of text, is that expected?

image

@prsadhuk
Copy link
Contributor Author

There seems to be less gap between text and icon in RTL Windows L&F case. The icon border looks different when the icon is to the left and right side of text, is that expected?

should be ok now in latest iteration..

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Oct 30, 2025
Copy link
Contributor

@honkar-jdk honkar-jdk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated fix LGTM apart from minor test suggestions.

/*
* @test id=windows
* @bug 4211052
* @bug 4211052 8370465
Copy link
Contributor

@honkar-jdk honkar-jdk Oct 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of multiple separate jtreg tags for each LaF we can combine it using @run tags as below:

/*
...
...
 * @run main/manual RightLeftOrientation windows
 * @run main/manual RightLeftOrientation motif
 * @run main/manual RightLeftOrientation metal
 */

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We decided to use it that way in [8346753](#25907 (comment)) sometime back

Rectangle rect = lr.getTextRect();

rect.x += lh.getAfterCheckIconGap();
if (menuItem.getHorizontalTextPosition() != SwingConstants.LEADING) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @azuev-java suggested, it might be a good idea to add the extra cases to the test.

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Oct 31, 2025
@openjdk openjdk bot added the ready Pull request is ready to be integrated label Oct 31, 2025
@prsadhuk
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Oct 31, 2025

Going to push as commit fc5df4a.
Since your change was applied there have been 121 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Oct 31, 2025
@openjdk openjdk bot closed this Oct 31, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Oct 31, 2025
@openjdk
Copy link

openjdk bot commented Oct 31, 2025

@prsadhuk Pushed as commit fc5df4a.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@prsadhuk prsadhuk deleted the JDK-8370465 branch October 31, 2025 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

client [email protected] integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

4 participants