Skip to content

JFrame Image, paint on top of it

I create a frame with an image with this code:

    JFrame f = new JFrame();
    try {
            f.setContentPane(new JLabel(new ImageIcon( File("image.jpg")))));
    catch (IOException e) {

That works fine, but now I want to paint something in that opened frame (on top of the image).

I’m quite new in Java, and I’ve allready tried to make a class that extends JFrame, with a paint(Graphics g) method in it, but it wouldn’t work, I only see the image…



Hmm well there are so many tutorials and without any code to go on its hard to say what you don’t know or have done wrong, look at: Java Updating Small Circles , and remember to not draw in the same colour as your image background or else you wont see anything no matter how hard you try 😉

7 People found this is helpful