pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Brown <gk_br...@verizon.net>
Subject Re: why does this paint twice?
Date Thu, 07 Mar 2013 17:22:26 GMT
paint() is called any time any region of the screen needs to be updated. This update could
be triggered by the application or it could be triggered by the OS (for example, if an overlapping
window is moved). 

The graphics context passed to paint() will be clipped to the bounds of the update region,
but you should generally optimize your component's drawing code so it only draws that part
that needs to be repainted.

On Mar 7, 2013, at 12:08 PM, "Schwartz, Cynthia L" <cynthia.l.schwartz@intel.com> wrote:

> I am writing a custom control and want to understand why this is painting twice. Complete
code below.
>  
> Thanks,
> Cynthia
>  
> public class PaintTest extends Application.Adapter {
>     private Window window = null;
>     private Waveform waveform = null;
>  
>     @Override
>     public void startup(Display display, Map<String, String> properties) {
>         window = new Window();
>                 waveform = new Waveform();
>                 window.setContent(waveform);
>         window.setMaximized(true);
>         window.open(display);
>     }
>  
>     @Override
>     public boolean shutdown(boolean optional) {
>         if (window != null) {
>             window.close();
>         }
>  
>         return false;
>     }
>  
>     public static void main(String[] args) {
>         DesktopApplicationContext.main(PaintTest.class, args);
>     }
>  
> }
>  
> package painttest;
>  
> import java.awt.Graphics2D;
> import org.apache.pivot.wtk.Panel;
>  
> public class Waveform extends Panel
> {
>        @Override
>         public void paint(Graphics2D graphics)
>     {
>                 System.out.println("Painting");
> }
> }
>  
>  


Mime
View raw message