changeset 4681:28fb85f284a4

7124562: [macosx] RobotTest0001 & RobotTest0002 are not functional in JCK-runtime-7 interactive Reviewed-by: art, anthony
author serb
date Wed, 25 Jan 2012 20:00:58 +0400
parents 1551cb104ed3
children 4a8cbf11c3b4
files src/macosx/classes/sun/lwawt/LWLabelPeer.java
diffstat 1 files changed, 23 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/macosx/classes/sun/lwawt/LWLabelPeer.java	Wed Jan 25 17:29:38 2012 +0300
+++ b/src/macosx/classes/sun/lwawt/LWLabelPeer.java	Wed Jan 25 20:00:58 2012 +0400
@@ -26,6 +26,8 @@
 
 package sun.lwawt;
 
+import java.awt.Dimension;
+import java.awt.FontMetrics;
 import java.awt.Label;
 import java.awt.peer.LabelPeer;
 
@@ -39,6 +41,9 @@
 final class LWLabelPeer extends LWComponentPeer<Label, JLabel>
         implements LabelPeer {
 
+    private static final int TEXT_XPAD = 5;
+    private static final int TEXT_YPAD = 1;
+
     LWLabelPeer(final Label target, final PlatformComponent platformComponent) {
         super(target, platformComponent);
     }
@@ -71,6 +76,24 @@
         }
     }
 
+    @Override
+    public Dimension getMinimumSize() {
+        int w = TEXT_XPAD;
+        int h = TEXT_YPAD;
+        final FontMetrics fm = getFontMetrics(getFont());
+        if (fm != null) {
+            final String text;
+            synchronized (getDelegateLock()) {
+                text = getDelegate().getText();
+            }
+            if (text != null) {
+                w += fm.stringWidth(text);
+            }
+            h += fm.getHeight();
+        }
+        return new Dimension(w, h);
+    }
+
     /**
      * Converts {@code Label} alignment constant to the {@code JLabel} constant.
      * If wrong Label alignment provided returns default alignment.