classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] FYI: JComponent painting fix


From: Roman Kennke
Subject: [cp-patches] FYI: JComponent painting fix
Date: Sat, 24 Sep 2005 22:51:44 +0200

Hi,

I fixed the Swing painting a little more. This finally removes the
flickers that have been visible from time to time (to be more precise:
when the AWT triggers repainting, which is entirely different from when
Swing triggers repainting).

Effectively, this adds a check in the paint() method if we are already
double-buffering (when we are called from AWT then we're not, that's
what caused the flickering) and if not, activate it by calling
paintDoubleBuffered. This looks a bit weird since paintDoubleBuffered
calls back into paint(), but that should actually work because the
isPaintingDoubleBuffered flag decides which branch in the if-else in
paint we go. When unwinding the call stack after painting, we go back
into paintDoubleBuffered and actually draw the buffer to screen. Maybe
meditate a little over this to understand...

You might ask why not do it like it has been done previously. The
double-buffering was always activated directly in paint() when double
buffering was enabled on the JComponent (and it was by default only
enabled on the JRootPane). This was not quite right for the following
reasons:

- in Sun's JDK, _all_ Swing components are doublebuffered-enabled by
default
- what if we want to have arbitrary Swing components displayed in an AWT
tree? With the old approach this was only possible with JRootPanes

So this hack improves the compatibility between AWT and Swing and also
removes some ugly screen flickering in one patch :-)

2005-09-24  Roman Kennke  <address@hidden>

        * javax/swing/JComponent.java
        (paint): Activate double buffering if it is not already
activated.
        (paintImmediately2): Prepare a component graphics object here
and
        call paintDoubleBuffered with this.
        (paintDoubleBuffered): Changed to work nicely with the new
paint()
        and paintImmediately2() methods.

/Roman

Attachment: JComponent.diff
Description: Text Data

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil


reply via email to

[Prev in Thread] Current Thread [Next in Thread]