src/macosx/classes/sun/lwawt/LWTextComponentPeer.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -46,14 +46,11 @@
 
 abstract class LWTextComponentPeer<T extends TextComponent, D extends JComponent>
         extends LWComponentPeer<T, D>
         implements DocumentListener, TextComponentPeer, InputMethodListener {
 
-    /**
-     * Character with reasonable value between the minimum width and maximum.
-     */
-    protected static final char WIDE_CHAR = 'w';
+
     private volatile boolean firstChangeSkipped;
 
     LWTextComponentPeer(final T target,
                         final PlatformComponent platformComponent) {
         super(target, platformComponent);

@@ -93,22 +90,20 @@
     /**
      * This method should be called under getDelegateLock().
      */
     abstract JTextComponent getTextComponent();
 
-    public Dimension getPreferredSize(final int rows, final int columns) {
+    public Dimension getMinimumSize(final int rows, final int columns) {
         final Insets insets;
         synchronized (getDelegateLock()) {
-            insets = getDelegate().getInsets();
+            insets = getTextComponent().getInsets();
         }
         final int borderHeight = insets.top + insets.bottom;
         final int borderWidth = insets.left + insets.right;
         final FontMetrics fm = getFontMetrics(getFont());
-        final int charWidth = (fm != null) ? fm.charWidth(WIDE_CHAR) : 10;
-        final int itemHeight = (fm != null) ? fm.getHeight() : 10;
-        return new Dimension(columns * charWidth + borderWidth,
-                             rows * itemHeight + borderHeight);
+        return new Dimension(fm.charWidth(WIDE_CHAR) * columns + borderWidth,
+                             fm.getHeight() * rows + borderHeight);
     }
 
     @Override
     public final void setEditable(final boolean editable) {
         synchronized (getDelegateLock()) {

@@ -185,10 +180,11 @@
         synchronized (getDelegateLock()) {
             return getTextComponent().getInputMethodRequests();
         }
     }
 
+    //TODO IN XAWT we just return true..
     @Override
     public final boolean isFocusable() {
         return getTarget().isFocusable();
     }