On Tue, 18 Dec 2007 23:37:15 +0000, rossum <rossum48@coldmail.com>
wrote:
Does anyone have any suggestions?
Thank you Daniel and Knute, the suggestion of using a BufferedImage
was exactly what I needed.
My test code now looks as below.  I use the offset variable to stagger
the plotting of the intermediate images so I can see them
individually; without the stagger they appear too quickly for me to
see that they are actually being displayed.  It looks ugly, but it is
only there for testing.
Thanks for your help,
rossum
// --- Partial Code Starts ---
class GraphPanel extends JPanel {                
    @Override
    public void paintComponent(Graphics g) {
        super.paintComponent(g);                      
        // Resize parent
        Container parent = this.getParent();
        this.setSize(parent.getWidth(), parent.getHeight());
        // Set up buffered image
        final int biXpos = 30;
        final int biYpos = 60;
        final int biHeight = 100;
        final int biWidth = 150;            
        BufferedImage bi = new BufferedImage(biWidth, biHeight, 
                BufferedImage.TYPE_INT_BGR);
        // Draw points on BufferedImage
        Graphics2D big = (Graphics2D)bi.createGraphics();
        final int xLimit = Math.min(biXpos + biWidth, getWidth()) 
                - biXpos;
        final int yLimit = Math.min(biYpos + biHeight, getHeight()) 
                - biYpos;
        int offset = 30;  // To stagger intermediate images
        for (int x = 0; x < xLimit; ++x) {
            for (int y = 0; y < yLimit; ++y) {
                big.setColor(pickColour(x, y));
                big.drawLine(x, y, x + 1, y + 1);
            } // end for
            if (x % 40 == 39) { 
                // Show intermediate progress
                g.drawImage(bi, biXpos+offset, biYpos+offset, null); 
                offset += 30;
            } // end if
        } // end for
        // Show final image
        g.drawImage(bi, biXpos, biYpos, null);
    } // end paintComponent()
    private Color pickColour(int x, int y) {
        switch ((x + y) % 3) {
            case 0: return Color.CYAN;
            case 1: return Color.GREEN;
            case 2: return Color.MAGENTA;
            default: return Color.BLACK;
        } // end switch
    } // end pickColor()
} // end class GraphPanel
// --- Partial Code Finishes ---
Whoops, be careful.
Your loop should be done outside of the EDT.  The synchronization will 
be a bit tricky, but I bet you could figure it out.  My suggestion is to 
and call repaint().
and the easy work on the EDT. This will keep your GUI responsive AND 
your user informed.