-
Enhancement
-
Resolution: Fixed
-
P4
-
1.3.0
-
beta
-
generic
-
generic
Name: boT120536 Date: 01/29/2001
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0)
Java HotSpot(TM) Client VM (build 1.3.0, mixed
mode)
Recently I've had a look into the sources and got quite a shock.
The update() method of java.awt.Component contains an ugly piece of code:
==== CODE ====
public void update(Graphics g) {
if ((this instanceof java.awt.Canvas) ||
(this instanceof java.awt.Panel) ||
(this instanceof java.awt.Frame) ||
(this instanceof java.awt.Dialog) ||
(this instanceof java.awt.Window)) {
g.clearRect(0, 0, width, height);
}
paint(g);
}
==== EOC ====
This looks like a quick hack which moved in during introduction of lightweight
components.
The use of instanceof is not only against all OO principles, it also slows down
execution of all extending classes which do not overwrite update() completely.
Furthermore the test for Frame and Dialog are unnecessary because they are
included in the Window test.
Please move the clearRect code to the classes where it belongs, i.e. Canvas,
Panel and Window.
(Review ID: 115927)
======================================================================