Domanda

It seems that JMenuItems don't automatically resize any image icon that's assigned to them, and from what I can tell, there isn't a property that makes them automatically do that, either.

Is anyone aware of a way that I can programatically resize the Icon for a JMenuItem? It seems like the Icon object is lacking functionality as it is, unless there's some other function that can actually deal with Icon objects.

È stato utile?

Soluzione

Extend the class and override it's paint method to resize the image before painting.

Altri suggerimenti

You can use Image class' method public Image getScaledInstance(int width, int height, int hints) to scale to desired size.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top