/[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.24 by mkoch, Wed Feb 16 12:36:22 2005 UTC revision 1.25 by rabbit78, Mon Feb 28 13:14:19 2005 UTC
# Line 1029  public class JList extends JComponent im Line 1029  public class JList extends JComponent im
1029     */     */
1030    public Dimension getPreferredScrollableViewportSize()    public Dimension getPreferredScrollableViewportSize()
1031    {    {
     int vis = getVisibleRowCount();  
     int nrows = getModel() == null ? 0 : getModel().getSize();  
     // FIXME: this is a somewhat arbitrary default, but.. ?  
     Dimension single = new Dimension(10, 10);;  
     Rectangle bounds = null;  
1032    
1033      if (vis > nrows)      Dimension retVal = getPreferredSize();
1034        if (getLayoutOrientation() == VERTICAL)
1035        {        {
1036          if (fixedCellWidth != -1 &&          if (fixedCellHeight != -1)
             fixedCellHeight != -1)  
1037            {            {
1038              single = new Dimension(fixedCellWidth, fixedCellHeight);              if (fixedCellWidth != -1)
1039            }                {
1040          else if (nrows != 0 && getUI() != null)                  int size = getModel().getSize();
1041            {                  retVal = new Dimension(fixedCellWidth, size * fixedCellHeight);
1042              Rectangle tmp = getUI().getCellBounds(this, 0, 0);                } // TODO: add else clause (preferredSize is ok for now)
1043              if (tmp != null)            } // TODO: add else clause (preferredSize is ok for now)
               single = tmp.getSize();  
           }  
       }  
     else if (getUI() != null)  
       {  
         return getUI().getCellBounds(this, 0, vis - 1).getSize();  
1044        }        }
1045        return retVal;
     return new Dimension(single.width, single.height * vis);  
1046    }    }
1047    
1048    /**    /**
# Line 1193  public class JList extends JComponent im Line 1181  public class JList extends JComponent im
1181     */     */
1182    public boolean getScrollableTracksViewportWidth()    public boolean getScrollableTracksViewportWidth()
1183    {    {
1184      return false;      Component parent = getParent();
1185        boolean retVal = false;
1186        if (parent instanceof JViewport)
1187          {
1188            JViewport viewport = (JViewport) parent;
1189            Dimension pref = getPreferredSize();
1190            if (viewport.getSize().width > pref.width)
1191              retVal = true;
1192            if ((getLayoutOrientation() == HORIZONTAL_WRAP)
1193                && (getVisibleRowCount() <= 0))
1194              retVal = true;
1195          }
1196        return retVal;
1197    }    }
1198    
1199    /**    /**
# Line 1206  public class JList extends JComponent im Line 1206  public class JList extends JComponent im
1206     */     */
1207    public boolean getScrollableTracksViewportHeight()    public boolean getScrollableTracksViewportHeight()
1208    {    {
1209      return false;      Component parent = getParent();
1210        boolean retVal = false;
1211        if (parent instanceof JViewport)
1212          {
1213            JViewport viewport = (JViewport) parent;
1214            Dimension pref = getPreferredSize();
1215            if (viewport.getSize().height > pref.height)
1216              retVal = true;
1217            if ((getLayoutOrientation() == VERTICAL_WRAP)
1218                && (getVisibleRowCount() <= 0))
1219              retVal = true;
1220          }
1221        return retVal;
1222    }    }
1223    
1224    public int getAnchorSelectionIndex()    public int getAnchorSelectionIndex()

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.25

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