/[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.16.2.10 by gnu_andrew, Sun Aug 7 18:34:11 2005 UTC revision 1.16.2.11 by gnu_andrew, Sat Sep 10 15:31:48 2005 UTC
# Line 596  public class JList extends JComponent im Line 596  public class JList extends JComponent im
596     * @return location of the cell located at the specified index in the list.     * @return location of the cell located at the specified index in the list.
597     */     */
598     public Point indexToLocation(int index){     public Point indexToLocation(int index){
599          //FIXME: Need to implement.       return getCellBounds(index, index).getLocation();
         return null;  
600     }     }
601    
602    /**    /**
# Line 605  public class JList extends JComponent im Line 604  public class JList extends JComponent im
604     * {@link #visibleRect} property, depending on the {@link     * {@link #visibleRect} property, depending on the {@link
605     * #componentOrientation} property.     * #componentOrientation} property.
606     *     *
607     * @return The index of the first visible list cell, or <code>-1</code>     * @return The index of the last visible list cell, or <code>-1</code>
608     * if none is visible.     * if none is visible.
609     */     */
610    public int getLastVisibleIndex()    public int getLastVisibleIndex()
# Line 615  public class JList extends JComponent im Line 614  public class JList extends JComponent im
614      r.translate(0, (int) r.getHeight() - 1);      r.translate(0, (int) r.getHeight() - 1);
615      if (or == ComponentOrientation.LEFT_TO_RIGHT)      if (or == ComponentOrientation.LEFT_TO_RIGHT)
616        r.translate((int) r.getWidth() - 1, 0);        r.translate((int) r.getWidth() - 1, 0);
617      return getUI().locationToIndex(this, r.getLocation());            if (getUI().locationToIndex(this, r.getLocation()) == -1
618            && indexToLocation(getModel().getSize() - 1).y < r.y)
619          return getModel().getSize() - 1;
620        return getUI().locationToIndex(this, r.getLocation());
621    }    }
622    
623    /**    /**
# Line 1030  public class JList extends JComponent im Line 1032  public class JList extends JComponent im
1032     */     */
1033    public Dimension getPreferredScrollableViewportSize()    public Dimension getPreferredScrollableViewportSize()
1034    {    {
1035        //If the layout orientation is not VERTICAL, then this will
1036      Dimension retVal = getPreferredSize();      //return the value from getPreferredSize. The current ListUI is
1037      if (getLayoutOrientation() == VERTICAL)      //expected to override getPreferredSize to return an appropriate value.
1038        if (getLayoutOrientation() != VERTICAL)
1039          return getPreferredSize();
1040        
1041        if (fixedCellHeight != -1 && fixedCellWidth != -1)
1042          return new Dimension(fixedCellWidth, getModel().getSize() *
1043                               fixedCellHeight);
1044    
1045        int prefWidth, prefHeight;
1046        if (fixedCellWidth != -1)
1047          prefWidth = fixedCellWidth;
1048        else
1049        {        {
1050          if (fixedCellHeight != -1)          prefWidth = 0;
1051            {          int size = getModel().getSize();
1052              if (fixedCellWidth != -1)          for (int i = 0; i < size; i++)
1053                {            if (getCellBounds(i, i).width > prefWidth)
1054                  int size = getModel().getSize();              prefWidth = getCellBounds(i, i).width;
1055                  retVal = new Dimension(fixedCellWidth, size * fixedCellHeight);        }
1056                } // TODO: add else clause (preferredSize is ok for now)      
1057            } // TODO: add else clause (preferredSize is ok for now)      if (getModel().getSize() == 0 && fixedCellWidth == -1)
1058          return new Dimension(256, 16 * getVisibleRowCount());
1059        else if (getModel().getSize() == 0)
1060          return new Dimension (fixedCellWidth, 16 * getVisibleRowCount());
1061        
1062        if (fixedCellHeight != -1)
1063          prefHeight = fixedCellHeight;
1064        else
1065          {
1066            prefHeight = getVisibleRowCount() * getCellBounds
1067              (getFirstVisibleIndex(), getFirstVisibleIndex()).height;
1068        }        }
1069      return retVal;      return new Dimension (prefWidth, prefHeight);
1070    }    }
1071    
1072    /**    /**

Legend:
Removed from v.1.16.2.10  
changed lines
  Added in v.1.16.2.11

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