Re: Self-changing font...



Rob McDonald wrote:
I guess what you're saying is that the repaint() call in the
componentResized is redundant. I can leave the size calculations there,
but
I don't need the repaint()....

Trying this, it doesn't work. It looks like the repaint() happens before
the calculations. So, it redraws with the old size. If you force a repaint
at that time, then it looks right.

If there was a way to force an order of the componentResized event and the
repaint(), that would work, but I'm pretty sure it isn't good practice to
rely on such an ordering...

Rob



Unfortunately here isn't any order. It is unknown in that order events arrive into EventQueue.
My experiment showed me that componentResized called before repaint.
That is why I think will be the best to keep your sizing calculation in paintComponent (you force one more repaint. May be it more expensive than calculating).
.



Relevant Pages

  • Re: Self-changing font...
    ... componentResized is redundant. ... I can leave the size calculations there, ... It looks like the repaint() happens before ... repaint, that would work, but I'm pretty sure it isn't good practice to ...
    (comp.lang.java.gui)
  • Re: Self-changing font...
    ... paintComponentis certainly helping. ... In the real program, some of the calculations I do on a resize are ... I don't want to do them every repaint. ...
    (comp.lang.java.gui)
  • Re: numerical analysis (composite numerical integration)
    ... I am horrified at my old trapezoidal rule. ... It had redundant ... calculations of f. ... double trapezoidal_rule(double a, double b, int n, double (*f)) ...
    (sci.math.num-analysis)