I guess I'd try to use HtmlRenderer.createLabel() instead of 'new JLabel()'
there - not sure if it will help, but might be worth a shot.

Jan

On Fri, Jan 3, 2020 at 5:24 AM Laszlo Kishalmi <[email protected]>
wrote:

> Dear all,
>
> I've recently experienced that NetBeans is unresponsive for 5-10 secs
> after the main screen opens. It does not really bother me as I open
> NetBeans up once or twice a week. I have ~46 projects loaded (mostly
> NetBeans modules).
>
> I've tried to profile what is happening. Though right now the profiler
> attachment crashes (an other issue maybe it is just on my machine) the
> JVM running the profiled NetBeans in 10-15 secs, I could get some
> valuable info.
>
> It seems there is a performance bottleneck in multitabs implementation.
>
> org.netbeans.core.multitabs.impl.TabDataRenderer.getPreferredWidth(Object)
> is being called several times spending considerable amount of time
> setting the text on a JLabel over and over:
>
>
> https://github.com/apache/netbeans/blob/06b3e677d9ea4dbd9987c8245fe5be776e8245f8/platform/core.multitabs/src/org/netbeans/core/multitabs/impl/TabDataRenderer.java#L144
>
> The purpose of these calls is to properly measure the width of the
> rendered component.
>
> I've tried to cheat by replacing:
>
> renderer.label.setText( text );
> renderer.label.setIcon( icon );
> res = renderer.getPreferredSize().width;
>
> With:
>
> AffineTransform transform = new AffineTransform();
> FontRenderContext frc = new FontRenderContext(transform, true, true);
> Font font = renderer.label.getFont();
> res = icon.getIconWidth() + renderer.label.getIconTextGap() + (int)
> font.getStringBounds(text, frc).getWidth();
>
> That, kind of, worked. The IDE starts up faster there is no visible
> side-effect (yet), however I would like someone who is more into swing
> to come up with a proper implementation, that handles HIDPI and html
> labels. Should not be hard, I just do not have the proper knowledge.
>
>
>

Reply via email to