> I would like to add an image (jpg) to a JPanel, but I cannot figure out
> how to do it.  How would I do this.

import com.sun.java.swing.*;
import java.awt.*;

ImageIcon oMyImage = new ImageIcon("some.jpg");

JPanel oPan = new JPanel(new BorderLayout());     
oPan.add(new JLabel( oMyImage ), "Center");

// Easy. Is't it? ;-)


// You can put .jpg/.gif files to JButton/JRadioBut/etc as good as to
JLabel
  • Images Shafiek Savahl
    • Paul V. Drobnich

Reply via email to