float w = rootView.getPreferredSpan(View.X_AXIS); float h = rootView.getPreferredSpan(View.Y_AXIS);
else {  rootView.setSize(Integer.MAX_VALUE, Integer.MAX_VALUE); } w = rootView.getPreferredSpan(View.X_AXIS); h = rootView.getPreferredSpan(View.Y_AXIS); } finally { if (doc instanceof AbstractDocument) ((AbstractDocument) doc).readUnlock(); }
  public Dimension getPreferredSize(JComponent c)  {    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);    Dimension size =  new Dimension((int) w + i.left + i.right,                         (int) h + i.top + i.bottom);    return size;  }