I'm creating a graphical roguelike game using Java. In the game, I'm painting a 2d array of Tile objects onto a JPanel. These Tile objects represent the ground. I have a .bmp sprite sheet that contains all of the textures I want to use to paint with. Every time the player moves, the tiles that are visible to the player need to be redrawn.
My question is a performance question. I have implemented this in the past to where I have the Tiles extend JPanel and each Tile just displays the appropriate segment of the sprite sheet using the bufferedImage.getSubImage(), while the parent JPanel simply calls paint() on all of the Tiles in the 2d array. This worked fine for the small 30x20 maps in the previous project, but I'm not sure it would work on the current game.
Should I use the same approach or is there some other possible solution that will speed up draw times? Should the Tile class extend some other Swing or AWT component such as BufferedImage or will that not have an effect?
Thanks.