/[classpath]/classpath/javax/swing/plaf/basic/BasicListUI.java
ViewVC logotype

Diff of /classpath/javax/swing/plaf/basic/BasicListUI.java

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

revision 1.12 by rabbit78, Sun Feb 27 13:51:05 2005 UTC revision 1.13 by rabbit78, Sun Feb 27 16:02:20 2005 UTC
# Line 79  public class BasicListUI extends ListUI Line 79  public class BasicListUI extends ListUI
79     * A helper class which listens for {@link ComponentEvent}s from     * A helper class which listens for {@link ComponentEvent}s from
80     * the JList.     * the JList.
81     */     */
82    class ComponentHandler extends ComponentAdapter {    private class ComponentHandler extends ComponentAdapter {
83    
84      /**      /**
85       * Called when the component is hidden. Invalidates the internal       * Called when the component is hidden. Invalidates the internal
# Line 94  public class BasicListUI extends ListUI Line 94  public class BasicListUI extends ListUI
94     * A helper class which listens for {@link FocusEvents}     * A helper class which listens for {@link FocusEvents}
95     * from the JList.     * from the JList.
96     */     */
97    class FocusHandler implements FocusListener    public class FocusHandler implements FocusListener
98    {    {
99      /**      /**
100       * Called when the JList acquires focus.       * Called when the JList acquires focus.
# Line 131  public class BasicListUI extends ListUI Line 131  public class BasicListUI extends ListUI
131     *     *
132     * @see javax.swing.JList#model     * @see javax.swing.JList#model
133     */     */
134    class ListDataHandler implements ListDataListener    public class ListDataHandler implements ListDataListener
135    {    {
136      /**      /**
137       * Called when a general change has happened in the model which cannot       * Called when a general change has happened in the model which cannot
# Line 169  public class BasicListUI extends ListUI Line 169  public class BasicListUI extends ListUI
169     * A helper class which listens for {@link ListSelectionEvent}s     * A helper class which listens for {@link ListSelectionEvent}s
170     * from the {@link JList}'s {@link ListSelectionModel}.     * from the {@link JList}'s {@link ListSelectionModel}.
171     */     */
172    class ListSelectionHandler implements ListSelectionListener    public class ListSelectionHandler implements ListSelectionListener
173    {    {
174      /**      /**
175       * Called when the list selection changes.         * Called when the list selection changes.  
# Line 185  public class BasicListUI extends ListUI Line 185  public class BasicListUI extends ListUI
185     * A helper class which listens for {@link MouseEvent}s     * A helper class which listens for {@link MouseEvent}s
186     * from the {@link JList}.     * from the {@link JList}.
187     */     */
188    class MouseInputHandler implements MouseInputListener    public class MouseInputHandler implements MouseInputListener
189    {    {
190      /**      /**
191       * Called when a mouse button press/release cycle completes       * Called when a mouse button press/release cycle completes
# Line 268  public class BasicListUI extends ListUI Line 268  public class BasicListUI extends ListUI
268     * Helper class which listens to {@link PropertyChangeEvent}s     * Helper class which listens to {@link PropertyChangeEvent}s
269     * from the {@link JList}.     * from the {@link JList}.
270     */     */
271    class PropertyChangeHandler implements PropertyChangeListener    public class PropertyChangeHandler implements PropertyChangeListener
272    {    {
273      /**      /**
274       * Called when the {@link JList} changes one of its bound properties.       * Called when the {@link JList} changes one of its bound properties.
# Line 302  public class BasicListUI extends ListUI Line 302  public class BasicListUI extends ListUI
302    }    }
303    
304    /** The current focus listener. */    /** The current focus listener. */
305    FocusHandler focusListener;    protected FocusHandler focusListener;
306    
307    /** The data listener listening to the model. */    /** The data listener listening to the model. */
308    ListDataHandler listDataListener;    protected ListDataHandler listDataListener;
309    
310    /** The selection listener listening to the selection model. */    /** The selection listener listening to the selection model. */
311    ListSelectionHandler listSelectionListener;    protected ListSelectionHandler listSelectionListener;
312    
313    /** The mouse listener listening to the list. */    /** The mouse listener listening to the list. */
314    MouseInputHandler mouseInputListener;    protected MouseInputHandler mouseInputListener;
315    
316    /** The property change listener listening to the list. */    /** The property change listener listening to the list. */
317    PropertyChangeHandler propertyChangeListener;    protected PropertyChangeHandler propertyChangeListener;
318    
319    /** The component listener that receives notification for resizing the    /** The component listener that receives notification for resizing the
320     * JList component.*/     * JList component.*/
321    ComponentListener componentListener;    private ComponentListener componentListener;
322    
323    /** Saved reference to the list this UI was created for. */    /** Saved reference to the list this UI was created for. */
324    JList list;    protected JList list;
325    
326    /** The height of a single cell in the list. */    /** The height of a single cell in the list. */
327    int cellHeight;    protected int cellHeight;
328    
329    /** The width of a single cell in the list. */    /** The width of a single cell in the list. */
330    int cellWidth;    protected int cellWidth;
331    
332    /**    /**
333     * An array of varying heights of cells in the list, in cases where each     * An array of varying heights of cells in the list, in cases where each
334     * cell might have a different height.     * cell might have a different height.
335     */     */
336    int[] cellHeights;    protected int[] cellHeights;
337    
338    /**    /**
339     * A simple counter. When nonzero, indicates that the UI class is out of     * A simple counter. When nonzero, indicates that the UI class is out of
340     * date with respect to the underlying list, and must recalculate the     * date with respect to the underlying list, and must recalculate the
341     * list layout before painting or performing size calculations.     * list layout before painting or performing size calculations.
342     */     */
343    int updateLayoutStateNeeded;    protected int updateLayoutStateNeeded;
344    
345    /**    /**
346     * Calculate the height of a particular row. If there is a fixed {@link     * Calculate the height of a particular row. If there is a fixed {@link
# Line 352  public class BasicListUI extends ListUI Line 352  public class BasicListUI extends ListUI
352     *     *
353     * @return The height, in pixels, of the specified row     * @return The height, in pixels, of the specified row
354     */     */
355    int getRowHeight(int row)    protected int getRowHeight(int row)
356    {    {
357      if (row < 0 || row >= cellHeights.length)      if (row < 0 || row >= cellHeights.length)
358        return -1;        return -1;
# Line 402  public class BasicListUI extends ListUI Line 402  public class BasicListUI extends ListUI
402     * @return The Y coordinate of the specified row, or <code>-1</code> if     * @return The Y coordinate of the specified row, or <code>-1</code> if
403     * the specified row number is invalid     * the specified row number is invalid
404     */     */
405    int convertRowToY(int row)    protected int convertRowToY(int row)
406    {    {
407      int y = 0;      int y = 0;
408      for (int i = 0; i < row; ++i)      for (int i = 0; i < row; ++i)
# Line 425  public class BasicListUI extends ListUI Line 425  public class BasicListUI extends ListUI
425     * @return The row number containing the specified Y value, or <code>-1</code>     * @return The row number containing the specified Y value, or <code>-1</code>
426     * if the specified Y coordinate is invalid     * if the specified Y coordinate is invalid
427     */     */
428    int convertYToRow(int y0)    protected int convertYToRow(int y0)
429    {    {
430      for (int row = 0; row < cellHeights.length; ++row)      for (int row = 0; row < cellHeights.length; ++row)
431        {        {
# Line 443  public class BasicListUI extends ListUI Line 443  public class BasicListUI extends ListUI
443     * #cellWidth} properties by examining the variouis properties of the     * #cellWidth} properties by examining the variouis properties of the
444     * {@link JList}.     * {@link JList}.
445     */     */
446    void updateLayoutState()    protected void updateLayoutState()
447    {    {
448      int nrows = list.getModel().getSize();      int nrows = list.getModel().getSize();
449      cellHeight = -1;      cellHeight = -1;
# Line 482  public class BasicListUI extends ListUI Line 482  public class BasicListUI extends ListUI
482     *     *
483     * @see #updateLayoutStateNeeded     * @see #updateLayoutStateNeeded
484     */     */
485    void damageLayout()    private void damageLayout()
486    {    {
487      updateLayoutStateNeeded = 1;      updateLayoutStateNeeded = 1;
488      list.revalidate();      list.revalidate();
# Line 492  public class BasicListUI extends ListUI Line 492  public class BasicListUI extends ListUI
492     * Calls {@link #updateLayoutState} if {@link #updateLayoutStateNeeded}     * Calls {@link #updateLayoutState} if {@link #updateLayoutStateNeeded}
493     * is nonzero, then resets {@link #updateLayoutStateNeeded} to zero.     * is nonzero, then resets {@link #updateLayoutStateNeeded} to zero.
494     */     */
495    void maybeUpdateLayoutState()    protected void maybeUpdateLayoutState()
496    {    {
497      if (updateLayoutStateNeeded != 0)      if (updateLayoutStateNeeded != 0)
498        {        {
# Line 521  public class BasicListUI extends ListUI Line 521  public class BasicListUI extends ListUI
521     *     *
522     * @see #uninstallDefaults     * @see #uninstallDefaults
523     */     */
524    void installDefaults()    protected void installDefaults()
525    {    {
526      UIDefaults defaults = UIManager.getLookAndFeelDefaults();      UIDefaults defaults = UIManager.getLookAndFeelDefaults();
527      list.setForeground(defaults.getColor("List.foreground"));      list.setForeground(defaults.getColor("List.foreground"));
# Line 535  public class BasicListUI extends ListUI Line 535  public class BasicListUI extends ListUI
535     * Resets to <code>null</code> those defaults which were installed in     * Resets to <code>null</code> those defaults which were installed in
536     * {@link #installDefaults}     * {@link #installDefaults}
537     */     */
538    void uninstallDefaults()    protected void uninstallDefaults()
539    {    {
540      UIDefaults defaults = UIManager.getLookAndFeelDefaults();      UIDefaults defaults = UIManager.getLookAndFeelDefaults();
541      list.setForeground(null);      list.setForeground(null);
# Line 550  public class BasicListUI extends ListUI Line 550  public class BasicListUI extends ListUI
550     *     *
551     * @see #uninstallListeners     * @see #uninstallListeners
552     */     */
553    void installListeners()    protected void installListeners()
554    {    {
555      list.addFocusListener(focusListener);      list.addFocusListener(focusListener);
556      list.getModel().addListDataListener(listDataListener);      list.getModel().addListDataListener(listDataListener);
# Line 564  public class BasicListUI extends ListUI Line 564  public class BasicListUI extends ListUI
564    /**    /**
565     * Detaches all the listeners we attached in {@link #installListeners}.     * Detaches all the listeners we attached in {@link #installListeners}.
566     */     */
567    void uninstallListeners()    protected void uninstallListeners()
568    {    {
569      list.removeFocusListener(focusListener);      list.removeFocusListener(focusListener);
570      list.getModel().removeListDataListener(listDataListener);      list.getModel().removeListDataListener(listDataListener);
# Line 577  public class BasicListUI extends ListUI Line 577  public class BasicListUI extends ListUI
577    /**    /**
578     * Installs keyboard actions for this UI in the {@link JList}.     * Installs keyboard actions for this UI in the {@link JList}.
579     */     */
580    void installKeyboardActions()    protected void installKeyboardActions()
581    {    {
582    }    }
583    
584    /**    /**
585     * Uninstalls keyboard actions for this UI in the {@link JList}.     * Uninstalls keyboard actions for this UI in the {@link JList}.
586     */     */
587    void uninstallKeyboardActions()    protected void uninstallKeyboardActions()
588    {    {
589    }    }
590    
# Line 623  public class BasicListUI extends ListUI Line 623  public class BasicListUI extends ListUI
623    }    }
624    
625    /**    /**
    * Gets the maximum size this list can assume.  
    *  
    * @param c The component to measure the size of  
    *  
    * @return A new Dimension representing the component's maximum size  
    */  
   public Dimension getMaximumSize(JComponent c)  
   {  
     return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);  
   }  
   
   /**  
626     * Gets the size this list would prefer to assume. This is calculated by     * Gets the size this list would prefer to assume. This is calculated by
627     * calling {@link #getCellBounds} over the entire list.     * calling {@link #getCellBounds} over the entire list.
628     *     *
# Line 657  public class BasicListUI extends ListUI Line 645  public class BasicListUI extends ListUI
645     * @param g The graphics context to paint in     * @param g The graphics context to paint in
646     * @param c The component to paint the background of     * @param c The component to paint the background of
647     */     */
648    public void paintBackground(Graphics g, JComponent c)    private void paintBackground(Graphics g, JComponent c)
649    {    {
650      Dimension size = getPreferredSize(c);      Dimension size = getPreferredSize(c);
651      Color save = g.getColor();      Color save = g.getColor();
# Line 679  public class BasicListUI extends ListUI Line 667  public class BasicListUI extends ListUI
667     * @param sel A selection model to provide to the cell renderer     * @param sel A selection model to provide to the cell renderer
668     * @param lead The lead selection index of the list     * @param lead The lead selection index of the list
669     */     */
670    void paintCell(Graphics g, int row, Rectangle bounds, ListCellRenderer rend,    protected void paintCell(Graphics g, int row, Rectangle bounds,
671                   ListModel data, ListSelectionModel sel, int lead)                   ListCellRenderer rend, ListModel data,
672                     ListSelectionModel sel, int lead)
673    {    {
674      boolean is_sel = list.isSelectedIndex(row);      boolean is_sel = list.isSelectedIndex(row);
675      boolean has_focus = false;      boolean has_focus = false;

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13

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