简体   繁体   中英

Force a certain icon size for JPopupMenu items?

In my program I have Actions that have different-sized icons, some intended for large buttons and some for small. I would like to reuse the same instance of each of these Actions when adding functionality to a JPopupMenu. Is there a way to force the large icons to be displayed at a smaller size?

The Action s API provides two icon keys. SMALL_ICON and LARGE_ICON_KEY

From the JavaDocs

The JMenuItem subclasses only use SMALL_ICON. All other buttons will use LARGE_ICON_KEY; if the value is null they use SMALL_ICON.

This would suggest that you should use the SMALL_ICON key for your actions to allow JMenuItems to display the small icon.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM