/[classpath]/classpath/javax/swing/JList.java
ViewVC logotype

Diff of /classpath/javax/swing/JList.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.37 by abalkiss, Thu Oct 20 20:53:14 2005 UTC revision 1.38 by abalkiss, Wed Oct 26 19:09:52 2005 UTC
# Line 1780  public class JList extends JComponent im Line 1780  public class JList extends JComponent im
1780      //return the value from getPreferredSize. The current ListUI is      //return the value from getPreferredSize. The current ListUI is
1781      //expected to override getPreferredSize to return an appropriate value.      //expected to override getPreferredSize to return an appropriate value.
1782      if (getLayoutOrientation() != VERTICAL)      if (getLayoutOrientation() != VERTICAL)
1783        return getPreferredSize();        return getPreferredSize();        
1784    
1785        int size = getModel().getSize();
1786        
1787        // Trivial case: if fixedCellWidth and fixedCellHeight were set
1788        // just use them
1789      if (fixedCellHeight != -1 && fixedCellWidth != -1)      if (fixedCellHeight != -1 && fixedCellWidth != -1)
1790        return new Dimension(fixedCellWidth, getModel().getSize() *        return new Dimension(fixedCellWidth, size * fixedCellHeight);
1791                             fixedCellHeight);          
1792        // If the model is empty we use 16 * the number of visible rows
1793        // for the height and either fixedCellWidth (if set) or 256
1794        // for the width
1795        if (size == 0)
1796          {
1797            if (fixedCellWidth == -1)
1798              return new Dimension(256, 16 * getVisibleRowCount());
1799            else
1800              return new Dimension(fixedCellWidth, 16 * getVisibleRowCount());
1801          }
1802    
1803      int prefWidth, prefHeight;      // Calculate the width: if fixedCellWidth was set use that, otherwise
1804        // use the preferredWidth
1805        int prefWidth;
1806      if (fixedCellWidth != -1)      if (fixedCellWidth != -1)
1807        prefWidth = fixedCellWidth;        prefWidth = fixedCellWidth;
1808      else      else
1809        {        prefWidth = getPreferredSize().width;
         prefWidth = 0;  
         int size = getModel().getSize();  
         for (int i = 0; i < size; i++)  
           if (getCellBounds(i, i).width > prefWidth)  
             prefWidth = getCellBounds(i, i).width;  
       }  
   
     if (getModel().getSize() == 0 && fixedCellWidth == -1)  
       return new Dimension(256, 16 * getVisibleRowCount());  
     else if (getModel().getSize() == 0)  
       return new Dimension (fixedCellWidth, 16 * getVisibleRowCount());  
1810    
1811        // Calculate the height: if fixedCellHeight was set use that, otherwise
1812        // use the height of the first row multiplied by the number of visible
1813        // rows
1814        int prefHeight;
1815      if (fixedCellHeight != -1)      if (fixedCellHeight != -1)
1816        prefHeight = fixedCellHeight;        prefHeight = fixedCellHeight;
1817      else      else
1818        {        prefHeight = getVisibleRowCount() * getCellBounds(0, 0).height;
1819          prefHeight = getVisibleRowCount() * getCellBounds  
           (getFirstVisibleIndex(), getFirstVisibleIndex()).height;  
       }  
1820      return new Dimension (prefWidth, prefHeight);      return new Dimension (prefWidth, prefHeight);
1821    }    }
1822    

Legend:
Removed from v.1.37  
changed lines
  Added in v.1.38

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26