Help: How to auto-resize the image icon to fit in the jlabel
Hi, anyone knows how to code to auto-resize the image icon to auto-fit into jLabel.
Here is my code for my button:
private JButton getJButtonSignUp() {
if (jButtonSignUp == null) {
jButtonSignUp = new JButton();
jButtonSignUp.setBounds(new Rectangle(270, 497, 133, 50));
jButtonSignUp.setIcon(new ImageIcon(getClass().getResource("/images/button.png")));
jButtonSignUp.setFont(new Font("Arial", Font.PLAIN, 14));
jButtonSignUp.setHorizontalTextPosition(SwingConst ants.CENTER);
jButtonSignUp.setForeground(Color.black);
jButtonSignUp.setText("Sign Up");
jButtonSignUp.setContentAreaFilled(false);
jButtonSignUp.setBorder(BorderFactory.createEmptyB order(2, 2, 2, 2));
}
return jButtonSignUp;
}
Thanks.