Вопрос

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.

Это было полезно?

Решение

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

Другие советы

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

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top