<Swing Dev> [13] RFR JDK-8213535:Windows HiDPI html lightweight tooltips are truncated

Prasanta Sadhukhan prasanta.sadhukhan at oracle.com
Thu Apr 30 09:42:15 UTC 2020


On 30-Apr-20 2:48 PM, Sergey Bylokhov wrote:
> On 4/29/20 8:29 pm, Prasanta Sadhukhan wrote:
>>> I could understand that we need to use some specific GC instead of 
>>> null(which is
>>> the default), but a force to use GC instead of another non-null GC 
>>> sounds not good, isn't it?
>>>
>> I couldn't get what you are trying to say...You have a problem with 
>> using getPreferredSize() in BasicToolTipUI#paint and you asked why 
>> can't we use the same setSize() as it is now. I found we cannot use 
>> that because JPanel.setSize() is wrong because it's GC was null when 
>> the "size" was calculated.
>
> As I mentioned, in the fix you do not replace the null value, but 
> replace any value if they are not equal to the current screen, is that 
> intentionally?
>
>  852             if (component.getGraphicsConfiguration() !=
>  853                     contents.getGraphicsConfiguration()) {
>  854                 AWTAccessor.getComponentAccessor().
>  855                         setGraphicsConfiguration((Component) 
> component,
>  856 contents.getGraphicsConfiguration());
>  857             }

OK. I now see your point of concern. No, it's not intentional so I have 
added the null check too

http://cr.openjdk.java.net/~psadhukhan/8213535/webrev.7/

>
> If we fix the JPanel's GC with the default GC (the same way we fix 
> ToolTip's GC) then we can continue to use setSize() in paint. If you 
> do not have problem with how we fix JTooltip's GC ,then what is the 
> problem with fixing JPanel's GC?
>
> It is unclear why we need to change GC of the panel. In the case of 
> TIP it is needed to calculate the size of the text which is set to the 
> TIP, but the panel does not have any text so why the GC of the panel 
> matters?
>
This is because LW popup is nothing but JPanel, as you might already 
know, so since BasicToolTipUI does not override size (but only override 
preferredSize, maximumSize, minimumSize) so it actually gives the 
already created JPanel size, which was wrongly created for NULL GC.
> Component createComponent(Component owner) {
>      JComponent component =new JPanel(new BorderLayout(),true);
>
>      component.setOpaque(true);
>      return component;
> }
BasicToolTipUI.java

public void paint(Graphics g, JComponent c) {
     Font font = c.getFont();
     FontMetrics metrics = SwingUtilities2.getFontMetrics(c, g, font);
     Dimension size = c.getSize(); // gets JPanel size

Regards
Prasanta

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/swing-dev/attachments/20200430/4da3b6b8/attachment.htm>


More information about the swing-dev mailing list