Sử dụng hàm để điều chỉnh hình ảnh phù hợp với kích thước của label
Trong đó:
+ “/img/” là packet chứa hình ảnh trong project và resources
+ lbl_Hinh là label để hiển thị hình ảnh
public void sethinh(String hinh)
{
ImageIcon icon = new ImageIcon(getClass().getResource("/img/"+hinh));
Image img = icon.getImage();
Image imgScale = img.getScaledInstance(lbl_Hinh.getWidth(), lbl_Hinh.getHeight(), Image.SCALE_SMOOTH);
ImageIcon scaledIcon = new ImageIcon(imgScale);
lbl_Hinh.setIcon(scaledIcon);
}