I wish to resize an ImageIcon within a JPanel, and I know there are suggestions everywhere, where it does not work for the following no matter how I edit it. The following is one of the many attempts, which i find closest to my aim.
With courtesy from: resizing a ImageIcon in a JButton
How can i rectify my code?
JLabel lblFoodPicUrl = new JLabel();
lblFoodPicUrl.setPreferredSize(new Dimension (50,50));
lblFoodPicUrl.setIcon (new ImageIcon (PlaceOrder.class.getResource("/Pictures/" + food_Pic_Url + ".jpg")));
lblFoodPicUrl.setHorizontalAlignment (SwingConstants.CENTER);
Image img = (Image) lblFoodPicUrl.getIcon();
Image newing = img.getScaledInstance(20, 20, java.awt.Image.SCALE_SMOOTH);
lblFoodPicUrl = new ImageIcon (newing);