Skip to content
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

MenuItem iconTextGap appears to be affecting margins #54

Closed
smileatom opened this issue Feb 1, 2020 · 3 comments
Closed

MenuItem iconTextGap appears to be affecting margins #54

smileatom opened this issue Feb 1, 2020 · 3 comments
Milestone

Comments

@smileatom
Copy link

Hi,

iconTextGap is supposed to govern the space between the icon<->text in a label component.
In JMenuItem this appears to be making the entire menu much larger when set.

Here is an example of iconTextGap 4: (Notice that the menu appears to be in general too wide)
Screen Shot 2020-02-01 at 11 32 07 AM

The same menu with iconTextGap of 10:

Screen Shot 2020-02-01 at 11 32 41 AM

With an increase in iconTextGap the menu gets wider and wider for no reason. Its also likely too wide at smaller values due to this issue (this is on MacOS).

On my non-retina display increasing iconTextGap from 4 to 10 increased the menu width by 17 pixels.

@DevCharly
Copy link
Collaborator

Looks like that iconTextGap is also used for the gap left to the icon, for the gap between text and accelerator, and gap right to accelerarator.

Here is popup menu with two equal menu items, but the second has a large iconTextGap:
image

Same happens in Metal Laf. On Nimbus and Windows Laf it is similar.

FlatLaf currently uses the default menu item layout that is implemented in sun.swing.MenuItemLayoutHelper, which uses iconTextGap for all gaps.

I plan to change this for issue #3. Then I can also fix this issue.

@smileatom
Copy link
Author

Interesting, I guess I assumed it was just the JLabel property for the menu item. Maybe since theres accelerator and hotkeys that can be displayed in the margins it was overloaded

DevCharly added a commit that referenced this issue Apr 26, 2020
- stable left margin (always space for one icon)
- right aligned accelerators
- larger gap between text and accelerator

current limitations:
- no HTML text support
- text not vertically aligned with other menu items if icons have different sizes
- vertical/horizontal alignment/textPosition properties are ignored

(issues #3 and #54)
@DevCharly DevCharly added this to the 0.34 milestone Apr 29, 2020
@DevCharly
Copy link
Collaborator

fixed in master branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants