For my project, I need to create customizable buttons. Except that I have a problem and I do not know how to solve it. I have a background image for my button and I would l
You can scale the image and create an ImageIcon. Something like this:
ImageIcon icon = new ImageIcon("img.png");
Image scaledImg = icon.getImage().getScaledInstance(newWidth, newHeight, java.awt.Image.SCALE_SMOOTH);
icon = new ImageIcon(scaledImg);
JButton button = new JButton(icon);
button.setHorizontalTextPosition(JButton.CENTER);
button.setVerticalTextPosition(JButton.CENTER);