title: Resizing icon to fit on JButton in Java?
body: <p>Whenever I set an icon for my JButton it is always not sized correctly. How can I resize the icon to fit the button fully? </p>
  
  <pre><code>final JButton btnSanic = new JButton();
  Image img = icon.getImage();
  Image newimg = img.getScaledInstance(width, height, java.awt.Image.SCALE_SMOOTH);
  icon = new ImageIcon(newimg);  
  btnSanic.setIcon(icon);
  </code></pre>