Re: paint program
From: Alex Hunsley (lard_at_tardis.ed.ac.molar.uk)
Date: 09/22/04
- Next message: C Williams: "Re: paint program"
- Previous message: Skip: "Re: paint program"
- In reply to: Paul Lutus: "Re: paint program"
- Next in thread: C Williams: "Re: paint program"
- Reply: C Williams: "Re: paint program"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 22 Sep 2004 18:27:57 GMT
Paul Lutus wrote:
> John Davison wrote:
>
> / ...
>
>
>>I'm guessing that Java probably doesn't keep track of the color of each
>>pixel of each component. It probably just says "draw whatever" and then
>>the underlying OS takes care of the pixels. (Someone correct me if I am
>>wrong here.)
>
>
> You're wrong here.
>
>
>>But you *can* draw to an image, then draw the image onto a component.
>
>
> And you can "draw" directly onto a component, using that component's paint()
> method. This is the most efficient way to address the original problem.
It's not efficient at all - as the user builds up pixels with their
paintbrush, would you redraw every pixel at each paint?
Much more efficient/easier to draw to a buffer, then draw the buffer (or
part thereof) to the screen when needed.
Swing *does* have double buffering built in, but it is per-paint time
and not a persistent image, which is what the OP needs from the sound of it.
Also, it's a good idea to override paintComponent rather than paint -
paint calls paintComponent amongst other things (like paintChildren and
paintBorders).
alex
- Next message: C Williams: "Re: paint program"
- Previous message: Skip: "Re: paint program"
- In reply to: Paul Lutus: "Re: paint program"
- Next in thread: C Williams: "Re: paint program"
- Reply: C Williams: "Re: paint program"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|