简体   繁体   中英

Responsive size of a JButton Icon

I am using the drag and drop system of netbeans to create my GUI. I created a button and added an icon to it, my problem is that the image is to big for the size I want the button to be.

Is there any way of making this icon having the same size as the button?

Is there any way of making this icon having the same size as the button?

The size of the button is determined by the size of the Icon.

You can create a new Image by using the Image.getScaledInstance(...) method and then create an new ImageIcon from the scaled image.

Depending on your exact requirement and usage of layout managers, you might be able to use the Stretch Icon which will adjust the size of the image as the size of the button is changed.

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