2D Game image rendering alternatives?

Hi everyone,

I got a question regarding image rendering for my 2D game.

I have read many ways of doing this but they practically they all took me to the same point. My project currently has this:

  • A class with a JFrame, with a basic game framework, starting a thread, running the game loop…
  • A class that extends JPanel, wich has the paintComponent() where i do all the painting.

Currently i just have a tile based isometric map drawn on the JPanel the problem comes that when i call repaint() within my game loop it redraws everything again (it even clears the screen if i got it right). And there are some images that i don’t feel they need to be rendered again.

So i read a lot about this and i found that i could pass parameters to repaint() so it paints only the things that i want. But i wasn’t able to pass the parameters for only drawing a determined image. Furthermore i also noticed that when i minimze or resize the window the paintComponent() method gets called again.

I feel like i’m not having the control of how my application renders so my question is, is this how it is commonly done? should i adapt to the JPanel paint or do i have an alternative? I also tried canvas and is more of the same i think?

I need to resolve this after moving on in my proyect.

Thanks in advance!