edit// my question is simpler than the other one so please just answer here. the other question looks too complicated for me to understand.
I want to add an image to a p
All you need to do is,
Graphics
object.just replace JPanel panel = new JPanel();
with below code.
JPanel panel = new JPanel() {
@Override
protected void paintComponent(Graphics g) {
Image image = null;
try {
image = ImageIO.read(new URL("https://www.google.co.in/images/branding/googlelogo/2x/googlelogo_color_120x44dp.png"));
} catch (IOException e) {
e.printStackTrace();
}
super.paintComponent(g);
g.drawImage(image, 0, 0, null);
}
};