I am currently developing a Call Telephony Integration Client for placetel.de on the basis of Spark Instant Messageing client and I noticed several repainting problems in spark.
After long hours researching the web I found the solution. In several component of spark there is the paintComponent(Graphics g) overriden. But they forgot to call ther super.paintComponent(g)
that is why the components always seemed just to write changes on top of the old state so it looked very messy.
public void paintComponent(Graphics g) {
//Super.paintComponent was missing and added by me!
super.paintComponent(g);
double scaleX = getWidth() / (double)backgroundImage.getWidth(null);
double scaleY = getHeight() / (double)backgroundImage.getHeight(null);
AffineTransform xform = AffineTransform.getScaleInstance(scaleX, scaleY);
((Graphics2D)g).drawImage(backgroundImage, xform, this);
}
No comments:
Post a Comment