1

I have a JPanel inside my bigger JPanel and i want to add image and change it in the run-time. And i need that image in the smaller panel resized to a fixed size in execution of the program. I managed to add image in it by using JLabel, but i can't fix its size, or resize it. Most of the suggestions i searched from internet didn't help me and actually, i didn't understand most of them. Here is my code:

public PhotoPanel() throws IOException {
    initComponents();
    jPanel1.setLayout(new GridLayout(1,1));

    BufferedImage myPicture = ImageIO.read(new URL("http://www3.pictures.fp.zimbio.com/Nicholas+Cage+David+Letterman+-EtX2RCI91al.jpg"));
    JLabel picLabel = new JLabel(new ImageIcon( myPicture ));
    jPanel1.add( picLabel );
} 

And that is the GUI of my program: enter image description here

I hope i explained it clearly.

mKorbel
  • 109,525
  • 20
  • 134
  • 319
Burak Özmen
  • 865
  • 2
  • 11
  • 28

0 Answers0