This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
When zooming a labelwidget (on linux) with the example test/component/ComponentTest.java the text sometimes doesn't fit into it's bounds. I debugged it a little bit and this is what I found: The method 'calculateClientArea()' on LabelWidget is called once and is used to determine it's bounds. In my case the result is : java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=204.0,h=13.962891] That results in a bounds with width 204 and height 12 (this is with zoomfactor 1.0) During zooming I now notice that with some zoomfactors the entire label doesn't fit into it's bounds. In the method 'paintWidget()' I call the method 'calculateClientArea()' and print the result to stdout (together with it's zoomfactor). These are the results: [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=204.0,h=13.962891] zoom=1.0 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=204.0,h=13.962891] zoom=1.0 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=201.18344,h=13.962891] zoom=1.014 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=198.05824,h=13.962891] zoom=1.03 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=217.76665,h=13.962891] zoom=1.0424 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=213.8282,h=13.962891] zoom=1.0615999999999999 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=211.2021,h=13.962891] zoom=1.0748 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=207.19241,h=13.962891] zoom=1.0956 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=205.69049,h=13.962891] zoom=1.1036 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=204.13667,h=13.962891] zoom=1.112 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=203.04118,h=13.962891] zoom=1.1179999999999999 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=201.95726,h=13.962891] zoom=1.1239999999999999 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=218.5067,h=13.962891] zoom=1.1304 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=217.27658,h=13.962891] zoom=1.1368 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=215.75818,h=13.962891] zoom=1.1448 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=214.55875,h=13.962891] zoom=1.1512 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=213.37247,h=13.962891] zoom=1.1576 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=211.90804,h=13.962891] zoom=1.1656 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=210.46355,h=13.962891] zoom=1.1736 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=208.82657,h=13.962891] zoom=1.1827999999999999 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=205.90198,h=13.962891] zoom=1.1996 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=205.83333,h=13.962891] zoom=1.2 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=204.52434,h=13.962891] zoom=1.2076799999999999 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=212.31944,h=13.962891] zoom=1.22928 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=208.09412,h=13.962891] zoom=1.25424 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=205.96596,h=13.962891] zoom=1.2671999999999999 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=203.80435,h=13.962891] zoom=1.28064 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=202.28795,h=13.962891] zoom=1.29024 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=215.99263,h=13.962891] zoom=1.3055999999999999 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=213.48108,h=13.962891] zoom=1.32096 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=211.02727,h=13.962891] zoom=1.33632 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=208.92603,h=13.962891] zoom=1.3497599999999998 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=206.57526,h=13.962891] zoom=1.36512 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=213.26604,h=13.962891] zoom=1.37856 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=210.62584,h=13.962891] zoom=1.39584 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=208.05028,h=13.962891] zoom=1.41312 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=205.74402,h=13.962891] zoom=1.42896 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=204.16669,h=13.962891] zoom=1.44 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=202.94897,h=13.962891] zoom=1.44864 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=215.0449,h=13.962891] zoom=1.46016 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=213.0281,h=13.962891] zoom=1.473984 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=210.7224,h=13.962891] zoom=1.4901119999999999 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=208.14769,h=13.962891] zoom=1.5085439999999999 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=205.63521,h=13.962891] zoom=1.5269759999999999 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=219.11455,h=13.962891] zoom=1.547136 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=216.0579,h=13.962891] zoom=1.569024 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=213.78197,h=13.962891] zoom=1.585728 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=210.87123,h=13.962891] zoom=1.607616 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=210.36356,h=13.962891] zoom=1.635264 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=206.86604,h=13.962891] zoom=1.662912 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=204.5982,h=13.962891] zoom=1.681344 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=202.6543,h=13.962891] zoom=1.6974719999999999 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=215.05751,h=13.962891] zoom=1.72512 [java] stringbounds = java.awt.geom.Rectangle2D$Float[x=0.0,y=-11.402344,w=214.69904,h=13.962891] zoom=1.728 You see that in some cases the width of the string exceeds the pre-calculated width of 204!. This is why the text sometimes doesn't fit. Maybe there should be a revalidate() of Widgets when a scene is being zoomed. (This would cost performance!)
Setting as duplicate #84012. Anyway thanks for trace of text bounds. Re: revalidate: yes, that's exactly why I do not want to implement it. Unfortunately I really do not have a solution except the temporary workaround or the revalidate solution. *** This issue has been marked as a duplicate of 84012 ***
One way to make sure it always fits is to take as initial width : rectangle.width = fontMetrics.charWidth('W') * label.length(); I know it is ugly but it works (even with strings that only contains spaces).
That could be a solution. I will think about it. If there will be no other way, I will implement it as you said. I have copied your comment to the issue #84012. Thanks.