66 |
import javax.swing.KeyStroke; |
import javax.swing.KeyStroke; |
67 |
import javax.swing.ListSelectionModel; |
import javax.swing.ListSelectionModel; |
68 |
import javax.swing.LookAndFeel; |
import javax.swing.LookAndFeel; |
|
import javax.swing.UIDefaults; |
|
69 |
import javax.swing.UIManager; |
import javax.swing.UIManager; |
70 |
import javax.swing.border.Border; |
import javax.swing.border.Border; |
71 |
import javax.swing.event.ChangeEvent; |
import javax.swing.event.ChangeEvent; |
72 |
import javax.swing.event.MouseInputListener; |
import javax.swing.event.MouseInputListener; |
73 |
|
import javax.swing.plaf.ActionMapUIResource; |
74 |
import javax.swing.plaf.ComponentUI; |
import javax.swing.plaf.ComponentUI; |
75 |
import javax.swing.plaf.InputMapUIResource; |
import javax.swing.plaf.InputMapUIResource; |
76 |
import javax.swing.plaf.TableUI; |
import javax.swing.plaf.TableUI; |
397 |
|
|
398 |
protected void installKeyboardActions() |
protected void installKeyboardActions() |
399 |
{ |
{ |
400 |
UIDefaults defaults = UIManager.getLookAndFeelDefaults(); |
InputMap ancestorMap = (InputMap) UIManager.get("Table.ancestorInputMap"); |
|
InputMap ancestorMap = (InputMap)defaults.get("Table.ancestorInputMap"); |
|
401 |
InputMapUIResource parentInputMap = new InputMapUIResource(); |
InputMapUIResource parentInputMap = new InputMapUIResource(); |
402 |
// FIXME: The JDK uses a LazyActionMap for parentActionMap |
// FIXME: The JDK uses a LazyActionMap for parentActionMap |
403 |
ActionMap parentActionMap = new ActionMap(); |
ActionMap parentActionMap = new ActionMapUIResource(); |
404 |
action = new TableAction(); |
action = new TableAction(); |
405 |
Object keys[] = ancestorMap.allKeys(); |
Object keys[] = ancestorMap.allKeys(); |
406 |
// Register key bindings in the UI InputMap-ActionMap pair |
// Register key bindings in the UI InputMap-ActionMap pair |
1193 |
TableCellRenderer rend, TableModel data, |
TableCellRenderer rend, TableModel data, |
1194 |
int rowLead, int colLead) |
int rowLead, int colLead) |
1195 |
{ |
{ |
1196 |
boolean rowSelAllowed = table.getRowSelectionAllowed(); |
Component comp = table.prepareRenderer(rend, row, col); |
|
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); |
|
|
|
|
1197 |
rendererPane.paintComponent(g, comp, table, bounds); |
rendererPane.paintComponent(g, comp, table, bounds); |
1198 |
|
|
1199 |
// FIXME: this is manual painting of the Caret, why doesn't the |
// FIXME: this is manual painting of the Caret, why doesn't the |
1200 |
// JTextField take care of this itself? |
// JTextField take care of this itself? |
1201 |
if (comp instanceof JTextField) |
if (comp instanceof JTextField) |
1243 |
width - gap.width + 1, |
width - gap.width + 1, |
1244 |
height - gap.height); |
height - gap.height); |
1245 |
if (bounds.intersects(clip)) |
if (bounds.intersects(clip)) |
1246 |
{ |
{ |
1247 |
paintCell(gfx, r, c, bounds, table.getCellRenderer(r, c), |
paintCell(gfx, r, c, bounds, table.getCellRenderer(r, c), |
1248 |
table.getModel(), |
table.getModel(), |
1249 |
table.getSelectionModel().getLeadSelectionIndex(), |
table.getSelectionModel().getLeadSelectionIndex(), |
1266 |
x = x0; |
x = x0; |
1267 |
Color save = gfx.getColor(); |
Color save = gfx.getColor(); |
1268 |
gfx.setColor(grid); |
gfx.setColor(grid); |
|
boolean paintedLine = false; |
|
1269 |
for (int c = 0; c < ncols && x < xmax; ++c) |
for (int c = 0; c < ncols && x < xmax; ++c) |
1270 |
{ |
{ |
1271 |
x += cols.getColumn(c).getWidth(); |
x += cols.getColumn(c).getWidth(); |
1272 |
gfx.drawLine(x, y0, x, ymax); |
gfx.drawLine(x, y0, x, ymax); |
|
paintedLine = true; |
|
1273 |
} |
} |
1274 |
gfx.setColor(save); |
gfx.setColor(save); |
1275 |
} |
} |
1280 |
y = y0; |
y = y0; |
1281 |
Color save = gfx.getColor(); |
Color save = gfx.getColor(); |
1282 |
gfx.setColor(grid); |
gfx.setColor(grid); |
|
boolean paintedLine = false; |
|
1283 |
for (int r = 0; r < nrows && y < ymax; ++r) |
for (int r = 0; r < nrows && y < ymax; ++r) |
1284 |
{ |
{ |
1285 |
y += height; |
y += height; |
1286 |
gfx.drawLine(x0, y, xmax, y); |
gfx.drawLine(x0, y, xmax, y); |
|
paintedLine = true; |
|
1287 |
} |
} |
1288 |
gfx.setColor(save); |
gfx.setColor(save); |
1289 |
} |
} |