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

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

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

revision 1.4 by mkoch, Thu Dec 16 19:10:04 2004 UTC revision 1.5 by mkoch, Fri Jan 7 18:32:49 2005 UTC
# Line 104  public class BasicTableUI Line 104  public class BasicTableUI
104    {    {
105      Point begin, curr;      Point begin, curr;
106    
     private int getRowForPoint(Point p)  
     {        
       int y0 = table.getLocation().y;  
       int nrows = table.getRowCount();  
       Dimension gap = table.getIntercellSpacing();  
       int height = table.getRowHeight() + (gap == null ? 0 : gap.height);  
       int y = p.y;  
       for (int i = 0; i < nrows; ++i)  
         {  
           if (0 <= y && y < height)  
             return i;  
           y -= height;  
         }  
       return -1;  
     }  
   
     private int getColForPoint(Point p)  
     {  
       int x0 = table.getLocation().x;  
       int ncols = table.getColumnCount();  
       Dimension gap = table.getIntercellSpacing();  
       TableColumnModel cols = table.getColumnModel();        
       int x = p.x;  
       for (int i = 0; i < ncols; ++i)  
         {  
           int width = cols.getColumn(i).getWidth() + (gap == null ? 0 : gap.width);  
           if (0 <= x && x < width)  
             return i;  
           x -= width;  
         }  
       return -1;  
     }  
   
107      private void updateSelection()      private void updateSelection()
108      {      {
109        if (table.getRowSelectionAllowed())        if (table.getRowSelectionAllowed())
110          {          {
111            int lo_row = getRowForPoint(begin);            int lo_row = table.rowAtPoint(begin);
112            int hi_row  = getRowForPoint(curr);            int hi_row  = table.rowAtPoint(curr);
113            ListSelectionModel rowModel = table.getSelectionModel();            ListSelectionModel rowModel = table.getSelectionModel();
114            if (lo_row != -1 && hi_row != -1)            if (lo_row != -1 && hi_row != -1)
115              rowModel.setSelectionInterval(lo_row, hi_row);              rowModel.setSelectionInterval(lo_row, hi_row);
# Line 150  public class BasicTableUI Line 117  public class BasicTableUI
117    
118        if (table.getColumnSelectionAllowed())        if (table.getColumnSelectionAllowed())
119          {          {
120            int lo_col = getColForPoint(begin);            int lo_col = table.columnAtPoint(begin);
121            int hi_col = getColForPoint(curr);            int hi_col = table.columnAtPoint(curr);
122            ListSelectionModel colModel = table.getColumnModel().getSelectionModel();            ListSelectionModel colModel = table.getColumnModel().getSelectionModel();
123            if (lo_col != -1 && hi_col != -1)            if (lo_col != -1 && hi_col != -1)
124              colModel.setSelectionInterval(lo_col, hi_col);              colModel.setSelectionInterval(lo_col, hi_col);

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

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