Java Code:
import java.awt.*;
import javax.swing.*;
public class addImage extends JFrame {
private ImageIcon img1;
private JLabel label1;
private ImageIcon img2;
private JLabel label2;
addImage(){
img1 = new ImageIcon(getClass().getResource("Image/1.jpg"));
label1 = new JLabel(img1);
add(label1).setSize(100, 100);
System.out.println();
img2 = new ImageIcon(getClass().getResource("Image/2.jpg"));
label2 = new JLabel(img2);
add(label2).setSize(50, 50);
}
public static void main(String[] args) {
addImage ai = new addImage();
ai.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ai.setVisible(true);
ai.pack();
ai.setTitle("Image Program");
}
}
i want to decrease the size of image 2 but code on line 18 is not working why????
i have attached the output kindly find it.
No comments:
Post a Comment