On 4/5/20 11:08 pm, Prasanta Sadhukhan wrote:
On 05-Apr-20 10:29 AM, Sergey Bylokhov wrote:
On 4/2/20 8:59 pm, Prasanta Sadhukhan wrote:
If we GC is correct in reset/pack step, but the View calculate wrong size(and update it
only after "graphicsConfiguration" property change) means that we calculate the
size of the View using wrong GC, why?
It's not the size of View, it's the preferredSize that is wrong. This is because tip's GC
is null before the tip is shown, so View's span is calculated accordingly. Only when View
isupdated when "graphicsConfiguration" is fired, then Tooltip GC is updated and
preferredSpan is calculated correctly.
It's to be remembered that the issue happens only when html text is shown in
ToolTip. If normal text is shown , there is no issue. I guess if it's a
question of wrong GC during popup reset/pack, then it will cause problem during
normal text rendering also, no?
If GC of the tip is null before showing then can we use default screen GC by
default? Same as in the java.awt.Window.initGC().
I tried but SwingUtilities.windowForComponent(tip) returns null so there is no
"Window" parent associated with tooltip so initGC() cannot be called on tip, as
I see.
Also, tip GC is null for normal text too, where it works. Only difference
between normal and html text is in calculation of
getPreferredSize/MaximumSize/MinimumSize where the size is updated based on
updated span calculation, so I have used updated preferredSize in my fix.
The normal text may work because the text and font metrics produce the
"correct" size which is not changed on the scaled screen, while the HTML
produce different size depending on the font metrics. Note that you should not call
Window.initGC() but use the similar logic somewhere in the code which initialize/show tip.
--
Best regards, Sergey.