I already did search on youtube and here and probably it is silly question but I couldn't find how to make it work.
Question is when I add pictures in my eclipse file they look like;
setLayout(new FlowLayout());
image1 = new ImageIcon(getClass().getResource("view.jpg"));
label1 = new JLabel(image1);
add(label1);
image2 = new ImageIcon(getClass().getResource("view1.jpg"));
label1 = new JLabel(image2);
add(label2); // here my code
Any ideas?
My got a use method to set icon for label, you can refer
private void loadAvartar(JLabel lbl, String path){
try {
BufferedImage image = ImageIO.read(new File(path));
ImageIcon icon = new ImageIcon(image.getScaledInstance(100, 100, 50));
lbl.setIcon(icon);
} catch (IOException | java.lang.NullPointerException e) {
lbl.setText("Failed");
}
}