Pregunta

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.

¿Fue útil?

Solución

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

Otros consejos

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top