I've been working on this for 2 days now and am hoping someone give me a tip. New to Java code so bear with me. I need to create 2 panels in a frame. Each frame must contain 2 images. Frame 1 must be a fixed width allowing the images to remain side by side. Frame 2 can fluctuate in size.

Here is a portion of my code -

//I declare my images......

ImageIcon pic1 = new ImageIcon ("face.jpg");
ImageIcon pic2 = new ImageIcon ("face2.jpg");

//declare my jlabels...........

 JLabel label1, label2, label3, label4;

      // Set up first subpanel
      JPanel subPanel1 = new JPanel();
      subPanel1.setPreferredSize (new Dimension(400, 100));
      subPanel1.setBackground (Color.green);
     	label1 = new JLabel ("Face", pic1, SwingConstants.LEFT);
		label2 = new JLabel ("Think",pic4, SwingConstants.RIGHT);
		subPanel1.add (label1);
		subPanel1.add (label2);

i'm not sure why, but the second image will not display. I've ensured that the image is valid because if i comment out pic1, the code will display pic 2. So i can get it to display one image in the pane but not two. I've increased the size of the panel to see if that was the issue but it's not helping.

Do i need to fix the size of each image?

Attachments face.jpg 7 KB thinkbyte.jpg 11.22 KB
label2 = new JLabel ("Think",pic4, SwingConstants.RIGHT);

I think you should be referencing pic2 here instead of pic4?

dear sir
i need the code for multiple images retrieval from database(mysql)and i want to show in frame/panel,please help me any one sir
thanks in advance......

This article has been dead for over six months. Start a new discussion instead.