This adds the getMinimumSize() method to the BasicTextUI and replaces a
'should never happen' comment with an assert statement.

2005-11-04  Roman Kennke  <[EMAIL PROTECTED]>

        * javax/swing/plaf/basic/BasicTextUI.java
        (getMinimumSize): New method.
        * javax/swing/text/FieldView.java
        (getPreferredSpan): Added assert that replaces a 'should never
happen'
        comment.

/Roman
Index: javax/swing/plaf/basic/BasicTextUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicTextUI.java,v
retrieving revision 1.50
diff -u -r1.50 BasicTextUI.java
--- javax/swing/plaf/basic/BasicTextUI.java	3 Nov 2005 16:05:08 -0000	1.50
+++ javax/swing/plaf/basic/BasicTextUI.java	4 Nov 2005 11:30:58 -0000
@@ -799,6 +799,18 @@
   }
 
   /**
+   * Returns the minimum size for text components. This returns the size
+   * of the component's insets.
+   *
+   * @return the minimum size for text components
+   */
+  public Dimension getMinimumSize(JComponent c)
+  {
+    Insets i = c.getInsets();
+    return new Dimension(i.left + i.right, i.top + i.bottom);
+  }
+
+  /**
    * Paints the text component.
    *
    * @param g the <code>Graphics</code> context to paint to
Index: javax/swing/text/FieldView.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/FieldView.java,v
retrieving revision 1.8
diff -u -r1.8 FieldView.java
--- javax/swing/text/FieldView.java	27 Oct 2005 15:09:32 -0000	1.8
+++ javax/swing/text/FieldView.java	4 Nov 2005 11:30:58 -0000
@@ -125,16 +125,16 @@
 
     try
       {
-	text = elem.getDocument().getText(elem.getStartOffset(),
-					  elem.getEndOffset());
+        text = elem.getDocument().getText(elem.getStartOffset(),
+                                          elem.getEndOffset());
       }
     catch (BadLocationException e)
       {
-	// This should never happen.
-	text = "";
+        assert false : e.toString();
+        text = "";
       }
-    
-    return fm.stringWidth(text) + 30;
+
+    return fm.stringWidth(text);
   }
 
   public int getResizeWeight(int axis)
_______________________________________________
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to