Index: javax/swing/JTable.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/JTable.java,v retrieving revision 1.61 diff -u -r1.61 JTable.java --- javax/swing/JTable.java 18 Nov 2005 21:46:19 -0000 1.61 +++ javax/swing/JTable.java 21 Nov 2005 13:13:21 -0000 @@ -1763,7 +1763,7 @@ if ((event.getFirstRow() ==TableModelEvent.HEADER_ROW) && autoCreateColumnsFromModel) - createDefaultColumnsFromModel(); + createDefaultColumnsFromModel(); // If the structure changes, we need to revalidate, since that might // affect the size parameters of the JTable. Otherwise we only need @@ -1796,7 +1796,6 @@ { if (point != null) { - int x0 = getLocation().x; int ncols = getColumnCount(); Dimension gap = getIntercellSpacing(); TableColumnModel cols = getColumnModel(); @@ -1826,7 +1825,6 @@ { if (point != null) { - int y0 = getLocation().y; int nrows = getRowCount(); int height = getRowHeight(); int y = point.y; @@ -1984,8 +1982,6 @@ } } - - public TableCellRenderer getCellRenderer(int row, int column) { TableCellRenderer renderer = @@ -2038,19 +2034,29 @@ int row, int column) { - boolean rsa = getRowSelectionAllowed(); - boolean csa = getColumnSelectionAllowed(); - boolean rs = rsa ? getSelectionModel().isSelectedIndex(row) : false; - boolean cs = csa ? columnModel.getSelectionModel().isSelectedIndex(column) : false; - boolean isSelected = ((rsa && csa && rs && cs) - || (rsa && !csa && rs) - || (!rsa && csa && cs)); - + + boolean rowSelAllowed = getRowSelectionAllowed(); + boolean colSelAllowed = getColumnSelectionAllowed(); + boolean isSel = false; + if (rowSelAllowed && colSelAllowed || !rowSelAllowed && !colSelAllowed) + isSel = isCellSelected(row, column); + else + isSel = isRowSelected(row) && getRowSelectionAllowed() + || isColumnSelected(column) && getColumnSelectionAllowed(); + + // Determine the focused cell. The focused cell is the cell at the + // leadSelectionIndices of the row and column selection model. + ListSelectionModel rowSel = getSelectionModel(); + ListSelectionModel colSel = getColumnModel().getSelectionModel(); + boolean hasFocus = hasFocus() && isEnabled() + && rowSel.getLeadSelectionIndex() == row + && colSel.getLeadSelectionIndex() == column; + return renderer.getTableCellRendererComponent(this, dataModel.getValueAt(row, convertColumnIndexToModel(column)), - isSelected, - false, // hasFocus + isSel, + hasFocus, row, column); } @@ -2216,7 +2222,6 @@ int lo = lsm.getMinSelectionIndex(); int hi = lsm.getMaxSelectionIndex(); int j = 0; - java.util.ArrayList ls = new java.util.ArrayList(); if (lo != -1 && hi != -1) { switch (lsm.getSelectionMode()) Index: javax/swing/plaf/basic/BasicTableUI.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicTableUI.java,v retrieving revision 1.37 diff -u -r1.37 BasicTableUI.java --- javax/swing/plaf/basic/BasicTableUI.java 15 Nov 2005 20:32:46 -0000 1.37 +++ javax/swing/plaf/basic/BasicTableUI.java 21 Nov 2005 13:13:21 -0000 @@ -1193,29 +1193,9 @@ TableCellRenderer rend, TableModel data, int rowLead, int colLead) { - boolean rowSelAllowed = table.getRowSelectionAllowed(); - boolean colSelAllowed = table.getColumnSelectionAllowed(); - boolean isSel = false; - if (rowSelAllowed && colSelAllowed || !rowSelAllowed && !colSelAllowed) - isSel = table.isCellSelected(row, col); - else - isSel = table.isRowSelected(row) && table.getRowSelectionAllowed() - || table.isColumnSelected(col) && table.getColumnSelectionAllowed(); - - // Determine the focused cell. The focused cell is the cell at the - // leadSelectionIndices of the row and column selection model. - ListSelectionModel rowSel = table.getSelectionModel(); - ListSelectionModel colSel = table.getColumnModel().getSelectionModel(); - boolean hasFocus = table.hasFocus() && table.isEnabled() - && rowSel.getLeadSelectionIndex() == row - && colSel.getLeadSelectionIndex() == col; - - Component comp = rend.getTableCellRendererComponent(table, - data.getValueAt(row, col), - isSel, hasFocus, row, col); - + Component comp = table.prepareRenderer(rend, row, col); rendererPane.paintComponent(g, comp, table, bounds); - + // FIXME: this is manual painting of the Caret, why doesn't the // JTextField take care of this itself? if (comp instanceof JTextField) @@ -1263,7 +1243,7 @@ width - gap.width + 1, height - gap.height); if (bounds.intersects(clip)) - { + { paintCell(gfx, r, c, bounds, table.getCellRenderer(r, c), table.getModel(), table.getSelectionModel().getLeadSelectionIndex(), @@ -1286,12 +1266,10 @@ x = x0; Color save = gfx.getColor(); gfx.setColor(grid); - boolean paintedLine = false; for (int c = 0; c < ncols && x < xmax; ++c) { x += cols.getColumn(c).getWidth(); gfx.drawLine(x, y0, x, ymax); - paintedLine = true; } gfx.setColor(save); } @@ -1302,12 +1280,10 @@ y = y0; Color save = gfx.getColor(); gfx.setColor(grid); - boolean paintedLine = false; for (int r = 0; r < nrows && y < ymax; ++r) { y += height; gfx.drawLine(x0, y, xmax, y); - paintedLine = true; } gfx.setColor(save); }