I would suggest adding it as ImageIcon:
ImageIcon image = new ImageIcon("image.jpeg"); add(image);
EDIT (how to add it add specific coordinates):
At first, a note, usually (99% of cases), is not recommended to host JComponents yourself. Use the LayoutManager to arrange them for you and handle resizing.
I will tell you how to position it correctly:
- Set LayoutManager to
null : setLayout(null) . - set
ImageIcon to specific coordinates: image.setLocation(x, y) .
Hidde
source share