Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've been working hard looking for a satisfactory solution and finally I've got it! That's what I have done:</p> <p>Class Animation does no more inheritates from JLabel it only implements ActionListener, in which <code>actionPerformed()</code> method I increment the frame to show for each one (I use Timer class). Therefore, Animation does no more override <code>paintComponent()</code> method (it's work for DisplayPanel).</p> <p>In DisplayPanel, I use thre global variables:</p> <pre><code>private BufferedImage _auxiliary_image; private ImageIcon _image2display; private ArrayList&lt;Animation&gt;;//I store there all the running animations there </code></pre> <p>And now, I override there the DisplayPanel <code>paintComponent()</code>, thus:</p> <pre><code> @Override public void paintComponent(Graphics g){ super.paintComponent(g); for (int i = 0; i &lt; _animations.size(); i++) { if(i==0){ _auxiliary_image.createGraphics().drawImage(_animations.get(i).getActual().getImage(), 0, 0, Color.white, null); }else{ _auxiliary_image.createGraphics().drawImage(_animations.get(i).getActual().getImage(), 0, 0, null); } } _image2display.setImage(_auxiliary_image); _image2display.paintIcon(this, g, 50, -200); } </code></pre> <p>The reason why I difference two cases, one for i==0 and another for the rest of frames is that on painting I saw a black background and the whole positions of the animation, so is this way that I solve the issue.</p> <p>Now, with 8 animations with 50 frames each one occuppies only 360 MB of memory instead 1.3 GB I get last time =) (I only paint one image, which results from merging all the frames to be printed at the same time for each animation).</p> <p>Thank you and I hope this could help!!!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload