Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>Update:</strong> good approach here: <a href="https://stackoverflow.com/questions/6824756/awt-custom-rendering-capture-smooth-resizes-and-eliminate-resize-flicker/6913597#6913597">AWT custom rendering - capture smooth resizes and eliminate resize flicker</a></p> <hr> <p>The answer here was to remove all blitting from the <code>paint()</code> thread i.e. only ever refresh from the backbuffer in the program thread. This is the opposite to the answer as suggested by Jochen Bedersdorfer, but his answer was never going to work for us because the program has its own scripting model that is integrated with the layout model which drives rendering, thus it all has to happen sequentially.</p> <p>(Speculation) Some of the problems stem from a less-than-stellar multiple monitor support in Java with accelerated graphics chipsets, as I ran in to <a href="https://stackoverflow.com/questions/6436944/java-illegalstateexception-buffers-have-not-been-created">this problem</a> when adapting to use BufferStrategy, which was a direct3d+Java discrepancy.</p> <p>Essentially <code>paint()</code> and <code>update()</code> are reduced to blocking calls. This works a lot better but has one drawback - there is no smooth resizing.</p> <pre><code>private class InnerFrame extends Frame() { public void update(Graphics g) { } public void paint(Graphics g) { } .... } </code></pre> <p>I ended up using a buffer strategy although I'm not 100% satisfied with this approach as it seems to me that it is inefficient to be rendering to an image, then copying the full image to the BufferStrategy and then performing a <code>show()</code> to screen.</p> <p>I also implemented a Swing-based alternative, but again I don't particularly like that. It uses a JLabel with an ImageIcon, whereby the program thread (not the EDT) draws to the Image that is wrapped by the ImageIcon.</p> <p>I'm sure there's a follow up question for me to ask when I have more time to look into this with more purpose, but for now I have two working implementations that more or less address the initial woes as posted here - and I learnt a helluva lot discovering them.</p>
 

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