I\'m making a scrolling 2D map/tile based game. Each tile (stored as tile[21][11] - 231 tiles total per map) can contain up to 21 values (stored as int[3][7]). While full-screen
My
Tiles
aren't any type ofJComponent
, they're just data. I call their container theMapPane
, which draws all of the tiles in itspaintComponent
.
Likewise, JTable
cells are just data rendered inside a JComponent
; the flyweight pattern, mentioned here, is still applicable: the goal is to omit any effort to render non-visible cells. Profile and self-time with a view toward optimizing the rendering; some approaches are examined in the KineticModel
cited here.
A BufferedImage
that needs no scaling is best. If you must scale, experiment with RenderingHints
related to interpolation type. If composition is too expensive, construct maps in the background using SwingWorker; publish()
them as they become available and process()
them on the EDT, as shown here.