简体   繁体   中英

How to display icon on the right side of menu items?

In my project I want to display icons on the right side of JMenuItem entries. Below is my code, but it displays icon on the left side of menu items.

Icon student2 = new ImageIcon(getClass().getResource("images/new-student.png"));
JMenuItem student = new JMenuItem("New students",student1);

i want to display icons on the right side of jemnu items

Try:

JMenuItem student = new JMenuItem(...);
student.setComponentOrientation(JComponent.ComponentOrientation.RIGHT_TO_LEFT);

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