-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
11.0.3-oracle
-
x86_64
-
windows_10
A DESCRIPTION OF THE PROBLEM :
I was able to resolve the issue by changing `BasicToggleButtonUI` to use `SwingUtilities2.getFontMetrics(c, g)` instead of `g.getFontMetrics()`. See source code for the patch.
---------- BEGIN SOURCE ----------
diff -r 175eb80c253a src/java.desktop/share/classes/javax/swing/plaf/basic/BasicToggleButtonUI.java
--- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicToggleButtonUI.java Wed Apr 03 02:25:37 2019 +0100
+++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicToggleButtonUI.java Wed Jun 12 14:12:22 2019 -0400
@@ -25,6 +25,7 @@
package javax.swing.plaf.basic;
+import sun.swing.SwingUtilities2;
import sun.awt.AppContext;
import java.awt.*;
@@ -82,7 +83,7 @@
ButtonModel model = b.getModel();
Dimension size = b.getSize();
- FontMetrics fm = g.getFontMetrics();
+ FontMetrics fm = SwingUtilities2.getFontMetrics(c, g);
Insets i = c.getInsets();
---------- END SOURCE ----------
FREQUENCY : always
I was able to resolve the issue by changing `BasicToggleButtonUI` to use `SwingUtilities2.getFontMetrics(c, g)` instead of `g.getFontMetrics()`. See source code for the patch.
---------- BEGIN SOURCE ----------
diff -r 175eb80c253a src/java.desktop/share/classes/javax/swing/plaf/basic/BasicToggleButtonUI.java
--- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicToggleButtonUI.java Wed Apr 03 02:25:37 2019 +0100
+++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicToggleButtonUI.java Wed Jun 12 14:12:22 2019 -0400
@@ -25,6 +25,7 @@
package javax.swing.plaf.basic;
+import sun.swing.SwingUtilities2;
import sun.awt.AppContext;
import java.awt.*;
@@ -82,7 +83,7 @@
ButtonModel model = b.getModel();
Dimension size = b.getSize();
- FontMetrics fm = g.getFontMetrics();
+ FontMetrics fm = SwingUtilities2.getFontMetrics(c, g);
Insets i = c.getInsets();
---------- END SOURCE ----------
FREQUENCY : always
- duplicates
-
JDK-8226215 JToggleButton text truncated with Windows L&F
-
- Closed
-