View v = getRootView(textComponent);
Dimension d = c.getSize(); Insets i = c.getInsets(); if (d.width > (i.left + i.right) && d.height > (i.top + i.bottom)) { rootView.setSize(d.width - i.left - i.right, d.height - i.top - i.bottom); } float w = rootView.getPreferredSpan(View.X_AXIS); float h = rootView.getPreferredSpan(View.Y_AXIS);
  public Dimension getPreferredSize(JComponent c)  {    View v = getRootView(textComponent);    float w = v.getPreferredSpan(View.X_AXIS);    float h = v.getPreferredSpan(View.Y_AXIS);    Insets i = c.getInsets();    return new Dimension((int) w + i.left + i.right,                         (int) h + i.top + i.bottom);  }