I have a right click popup menu that works fine.
I now want to add a little image next to the text.
I managed to display the image in the popupmenu but its the full size version.
what I want to know is:
is there a way to automatically reize the icon to be the right size ( same as the text ) or do I have to resize the image?
Jason
You have to resize the Icon to be whatever size you want it to be. Something like:
ImageIcon icon = new ImageIcon( ... );
Image image = icon.getImage().getScaledInstance(64, 64, Image.SCALE_SMOOTH);
JLabel label = new JLabel( new ImageIcon( image ) );
来源:https://stackoverflow.com/questions/6295195/java-swing-popup-display-small-icon-in-menu