Yes - all components ultimately need to implement paint() in one way or another.
On Mar 7, 2013, at 1:03 PM, "Schwartz, Cynthia L" <[email protected]> wrote: > That code = Code that overrides the paint method. Is that the best way to > paint a custom widget in Pivot? It seems as if it would be, going to Java2D > directly, but I just wanted to make sure since I am still learning of Pivot's > capabilities and power. > > Thanks, > Cynthia > > -----Original Message----- > From: Greg Brown [mailto:[email protected]] > Sent: Thursday, March 07, 2013 9:59 AM > To: [email protected] > Subject: Re: why does this paint twice? > > What code? > > On Mar 7, 2013, at 12:30 PM, "Schwartz, Cynthia L" > <[email protected]> wrote: > >> Is that code the best (fastest, most efficient...) way to accomplish the >> painting of a custom control in Pivot? >> >> Thanks >> Cynthia >> >> -----Original Message----- >> From: Greg Brown [mailto:[email protected]] >> Sent: Thursday, March 07, 2013 9:22 AM >> To: [email protected] >> Subject: Re: why does this paint twice? >> >> 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" >> <[email protected]> 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"); } } >>> >>> >> >
