Hi oi,
I may be off base since we don't have your code, but typically with
Swing you should override paintComponent() rather than paint(), unless you
are absolutely sure that's what you want to do. So, I'd do the code like
this:
bufImage = pan(<Parameters>);
// paint(g);
repaint();
Of course, I see that you are passing a graphics, so I don't know your
logic. Anyhow, in paintComponent(), the trick is usually to first have code
like this:
// ensure proper background handling
if( isOpaque() ) { super.paintComponent( g ); }
JPanels, unlike most JComponents are opaque by default. Opaque components
are cleared in the standard paintComponent(). Two optimization variations
are, set a state flag when the image changes, then :
if( bStateChanged )
{
// ensure proper background handling
if( isOpaque() ) { super.paintComponent( g ); }
bStateChanged = false;
}
OR save a call, like:
if( bStateChanged )
{
// use fillRect() for the size of the JPanel using background color.
// this is essentially what paintComponent() does for opaques
bStateChanged = false;
}
HTH,
Joe Sam
Joe Sam Shirah
Autumn Software
What you don't know DOES hurt you...and your business
___________________________________________
-----Original Message-----
From: Ole Baunb�k Jensen <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Tuesday, November 30, 1999 5:16 PM
Subject: [JAVA2D] paint/repaint/refresh/update?
>Hello
>
>In my GUI, i have a problem repainting the panel(jpanel) so that the image
>that has to be updated, does not remain in the background? ive tried many
>approaches, like paint repaint refresh update in the JComponent/graphics
>class, does anyone have some examples showing how this should be done
>properly.
>I have this situation:
>bufImage = pan(<Parameters>);
>paint(g);
>
>bufImage is the new picture i have to display in a JPanel. If the old
>bufImage is bigger then the new resized(result of my pan-function), then
>i still
>have the old bufImage in the rest of the panel, behind the new image.
>I have tried refreshing the whole panel and update the container.
>
>oi
>
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".