I'm currently developping a roguelike game, using Swing. I'm using an array of JLabel to display the tiles. When the user input a direction, I redraw the whole tab using the following method (I'm using simplified variable name here) :
for (int i=0 ; i<array.length ; i++){
for(int j=0 ; j<array[i].length ; j++){
this.remove(array[i][j]);
array[i][j] = new JLabel(new ImageIcon(TILEARRAY[i][j]));
this.add(array[i][j]);
this.validate();
}
}
But it's very heavy to deal with, about 0.5s to redraw the whole panel, and when I press the direction, it can't draw fast enough to have a real-time display (it actually does the loop, along the waiting time, and when the whole displacement has been done, draws). I'd like to know if there's a easier and faster way to achieve this, with a " smooth " feeling (let's say like in Stone Soup Dungeon Crawl (tiles version)), using Swing.
Every suggestion on an efficient 2D library for Java is welcome too. I know there is Slick2D, but is there any good other library for this kind of games ?
Thanks
(sorry if my english is bad, I'm not a native speaker of English)