if (list.getModel().getSize() == 0)
int size = list.getModel().getSize(); if (size == 0)
  public Dimension getPreferredSize(JComponent c)  {    if (list.getModel().getSize() == 0)      return new Dimension(0, 0);    Rectangle bounds = getCellBounds(list, 0, list.getModel().getSize() - 1);    return bounds.getSize();  }