Dustin Lang <[EMAIL PROTECTED]> writes:
> Let's make the assumption that I haven't made a glaring error (may not be
> a reasonable assumption since my brain is a bit fried), and assume that
> this is in fact a bug. Now, this is by no means a major bug, and I'm sure
> I could do a work-around, but if repaint(10L) is called, shouldn't paint
> get called within 10 ms, regardless of what other threads are executing?
> Or am I on crack?
I's a little tricky when you're out on the event dispatching thread ;-)
The repaint calls will be batched up until the event is processed.
> import java.awt.*;
>
> public class Light extends Canvas {
>
> int dia;
>
> public Light(int d) {
> dia = d;
> }
>
> public Dimension getPreferredSize() {
> return new Dimension(dia,dia);
> }
>
> public void setColor(Color c) {
> setForeground(c);
> System.out.println("Repaint!");
// repaint(10L) removed
Graphics g = getGraphics();
if (g != null) {
update(g); // do an immediate update
}
}
> }
>
> public void update(Graphics g) {
> System.out.println("Update!");
> paint(g);
> }
>
> public void paint(Graphics g) {
> System.out.println("Painting (color is " + getForeground().toString()
>+ ")");
> g.setColor(getBackground());
> g.fillRect(0,0,getSize().width,getSize().height);
> g.setColor(getForeground());
> g.fillOval(0,0,dia,dia);
> }
> }
Jürgen
--
Juergen Kreileder, Universitaet Dortmund, Lehrstuhl Informatik V
Baroper Strasse 301, D-44221 Dortmund, Germany
Phone: ++49 231/755-5806, Fax: ++49 231/755-5802