I have an application, in which I want to displaying a number of image components. Each item of this will be a custom jcomponent
which will has the image in a BufferedImage
object to draw it in paintcomponents(Graphics g)
overrided method. I will also use a JPanel
for the grid with a gridlayout
or flowlayout
for place the custom image jcomponents
, also the grid's layout will be inside an JscrollPane
.
My question is what happens, when the number of the images I must to put into the grid will become big. With use of the jscrollpane
, the number of the components so the number of the images must be draw will be smaller like 20-30 components, but each component inserted into the grid will have an object of BufferedImage to keep the corresponding image. This is bad for the perfomance and the memory consuption? May can use some pattern? for example if I use a main point of reference to load the images from disk to bufferedimage
and depending of which rectangle of the scrollpane
the user then release some bufferedimage where they putted away in the grid from the current position of the jscrollpane
?
Thank you.