/[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.7 by mkoch, Mon May 31 21:12:06 2004 UTC revision 1.8 by mark, Thu Jul 22 19:45:39 2004 UTC
# Line 121  public class BasicListUI extends ListUI Line 121  public class BasicListUI extends ListUI
121       */       */
122      public void contentsChanged(ListDataEvent e)      public void contentsChanged(ListDataEvent e)
123      {      {
       // System.err.println(this + ".contentsChanged(" + e + ")");  
124        BasicListUI.this.damageLayout();        BasicListUI.this.damageLayout();
125      }      }
126    
# Line 132  public class BasicListUI extends ListUI Line 131  public class BasicListUI extends ListUI
131       */       */
132      public void intervalAdded(ListDataEvent e)      public void intervalAdded(ListDataEvent e)
133      {      {
       // System.err.println(this + ".intervalAdded(" + e + ")");  
134        BasicListUI.this.damageLayout();        BasicListUI.this.damageLayout();
135      }      }
136    
# Line 143  public class BasicListUI extends ListUI Line 141  public class BasicListUI extends ListUI
141       */       */
142      public void intervalRemoved(ListDataEvent e)      public void intervalRemoved(ListDataEvent e)
143      {      {
       // System.err.println(this + ".intervalRemoved(" + e + ")");  
144        BasicListUI.this.damageLayout();        BasicListUI.this.damageLayout();
145      }      }
146    }    }
# Line 161  public class BasicListUI extends ListUI Line 158  public class BasicListUI extends ListUI
158       */       */
159      public void valueChanged(ListSelectionEvent e)      public void valueChanged(ListSelectionEvent e)
160      {      {
       //       System.err.println(this + ".valueChanged(" + e + ")");  
161      }      }
162    }    }
163    
# Line 189  public class BasicListUI extends ListUI Line 185  public class BasicListUI extends ListUI
185       */       */
186      public void mousePressed(MouseEvent event)      public void mousePressed(MouseEvent event)
187      {      {
       // System.err.println("got mouse click event " + event);  
188        int row = BasicListUI.this.convertYToRow(event.getY());        int row = BasicListUI.this.convertYToRow(event.getY());
189        if (row == -1)        if (row == -1)
190          return;          return;
191    
       // System.err.println("clicked on row " + row);  
192        BasicListUI.this.list.setSelectedIndex(row);        BasicListUI.this.list.setSelectedIndex(row);
193      }      }
194    
# Line 262  public class BasicListUI extends ListUI Line 256  public class BasicListUI extends ListUI
256       */       */
257      public void propertyChange(PropertyChangeEvent e)      public void propertyChange(PropertyChangeEvent e)
258      {      {
       // System.err.println(this + ".propertyChange(" + e + ")");  
259        if (e.getSource() == BasicListUI.this.list)        if (e.getSource() == BasicListUI.this.list)
260          {          {
261            if (e.getOldValue() != null && e.getOldValue() instanceof ListModel)            if (e.getOldValue() != null && e.getOldValue() instanceof ListModel)
# Line 357  public class BasicListUI extends ListUI Line 350  public class BasicListUI extends ListUI
350     */     */
351    public Rectangle getCellBounds(JList l, int index1, int index2)    public Rectangle getCellBounds(JList l, int index1, int index2)
352    {    {
353        maybeUpdateLayoutState();
354    
355      if (l != list || cellWidth == -1)      if (l != list || cellWidth == -1)
356        return null;        return null;
357    
# Line 366  public class BasicListUI extends ListUI Line 361  public class BasicListUI extends ListUI
361                                         getRowHeight(lo));                                         getRowHeight(lo));
362      Rectangle hibounds = new Rectangle(0, convertRowToY(hi), cellWidth,      Rectangle hibounds = new Rectangle(0, convertRowToY(hi), cellWidth,
363                                         getRowHeight(hi));                                         getRowHeight(hi));
364    
365      return lobounds.union(hibounds);      return lobounds.union(hibounds);
366    }    }
367    
# Line 408  public class BasicListUI extends ListUI Line 404  public class BasicListUI extends ListUI
404        {        {
405          int h = getRowHeight(row);          int h = getRowHeight(row);
406    
         // System.err.println("convertYToRow(" + y0 + ") vs. " + h);  
407          if (y0 < h)          if (y0 < h)
408            return row;            return row;
409          y0 -= h;          y0 -= h;
# Line 468  public class BasicListUI extends ListUI Line 463  public class BasicListUI extends ListUI
463     */     */
464    void maybeUpdateLayoutState()    void maybeUpdateLayoutState()
465    {    {
     // System.err.println(this + ".maybeUpdateLayoutState()");  
466      if (updateLayoutStateNeeded != 0)      if (updateLayoutStateNeeded != 0)
467        {        {
468          updateLayoutState();          updateLayoutState();
# Line 576  public class BasicListUI extends ListUI Line 570  public class BasicListUI extends ListUI
570      installDefaults();      installDefaults();
571      installListeners();      installListeners();
572      installKeyboardActions();      installKeyboardActions();
     // System.err.println(this + ".installUI()");  
573      maybeUpdateLayoutState();      maybeUpdateLayoutState();
574    }    }
575    
# Line 618  public class BasicListUI extends ListUI Line 611  public class BasicListUI extends ListUI
611     */     */
612    public Dimension getPreferredSize(JComponent c)    public Dimension getPreferredSize(JComponent c)
613    {    {
     maybeUpdateLayoutState();  
614      if (list.getModel().getSize() == 0)      if (list.getModel().getSize() == 0)
615        return new Dimension(0, 0);        return new Dimension(0, 0);
616      int nrows = Math.min(list.getVisibleRowCount(), list.getModel().getSize());      Rectangle bounds = getCellBounds(list, 0, list.getModel().getSize() - 1);
     Rectangle bounds = getCellBounds(list, 0, nrows - 1);  
617      return bounds.getSize();      return bounds.getSize();
618    }    }
619    
# Line 678  public class BasicListUI extends ListUI Line 669  public class BasicListUI extends ListUI
669     */     */
670    public void paint(Graphics g, JComponent c)    public void paint(Graphics g, JComponent c)
671    {    {
672      int nrows = Math.min(list.getVisibleRowCount(), list.getModel().getSize());      int nrows = list.getModel().getSize();
673      if (nrows == 0)      if (nrows == 0)
674        return;        return;
675    
# Line 687  public class BasicListUI extends ListUI Line 678  public class BasicListUI extends ListUI
678      ListModel model = list.getModel();      ListModel model = list.getModel();
679      ListSelectionModel sel = list.getSelectionModel();      ListSelectionModel sel = list.getSelectionModel();
680      int lead = sel.getLeadSelectionIndex();      int lead = sel.getLeadSelectionIndex();
681        Rectangle clip = g.getClipBounds();
682      paintBackground(g, list);      paintBackground(g, list);
683    
684      for (int row = 0; row < nrows; ++row)      for (int row = 0; row < nrows; ++row)
685        {        {
686          Rectangle bounds = getCellBounds(list, row, row);          Rectangle bounds = getCellBounds(list, row, row);
687            if (bounds.intersects(clip))
688          paintCell(g, row, bounds, render, model, sel, lead);          paintCell(g, row, bounds, render, model, sel, lead);
689        }        }
690    }    }

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

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