104 |
{ |
{ |
105 |
Point begin, curr; |
Point begin, curr; |
106 |
|
|
107 |
private void updateSelection() |
private void updateSelection(boolean controlPressed) |
108 |
{ |
{ |
109 |
if (table.getRowSelectionAllowed()) |
if (table.getRowSelectionAllowed()) |
110 |
{ |
{ |
112 |
int hi_row = table.rowAtPoint(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); |
{ |
116 |
|
if (controlPressed && rowModel.getSelectionMode() != ListSelectionModel.SINGLE_SELECTION) |
117 |
|
rowModel.addSelectionInterval(lo_row, hi_row); |
118 |
|
else |
119 |
|
rowModel.setSelectionInterval(lo_row, hi_row); |
120 |
|
} |
121 |
} |
} |
122 |
|
|
123 |
if (table.getColumnSelectionAllowed()) |
if (table.getColumnSelectionAllowed()) |
126 |
int hi_col = table.columnAtPoint(curr); |
int hi_col = table.columnAtPoint(curr); |
127 |
ListSelectionModel colModel = table.getColumnModel().getSelectionModel(); |
ListSelectionModel colModel = table.getColumnModel().getSelectionModel(); |
128 |
if (lo_col != -1 && hi_col != -1) |
if (lo_col != -1 && hi_col != -1) |
129 |
colModel.setSelectionInterval(lo_col, hi_col); |
{ |
130 |
|
if (controlPressed && colModel.getSelectionMode() != ListSelectionModel.SINGLE_SELECTION) |
131 |
|
colModel.addSelectionInterval(lo_col, hi_col); |
132 |
|
else |
133 |
|
colModel.setSelectionInterval(lo_col, hi_col); |
134 |
|
} |
135 |
} |
} |
136 |
} |
} |
137 |
|
|
141 |
public void mouseDragged(MouseEvent e) |
public void mouseDragged(MouseEvent e) |
142 |
{ |
{ |
143 |
curr = new Point(e.getX(), e.getY()); |
curr = new Point(e.getX(), e.getY()); |
144 |
updateSelection(); |
updateSelection(e.isControlDown()); |
145 |
} |
} |
146 |
public void mouseEntered(MouseEvent e) |
public void mouseEntered(MouseEvent e) |
147 |
{ |
{ |
156 |
{ |
{ |
157 |
begin = new Point(e.getX(), e.getY()); |
begin = new Point(e.getX(), e.getY()); |
158 |
curr = new Point(e.getX(), e.getY()); |
curr = new Point(e.getX(), e.getY()); |
159 |
updateSelection(); |
updateSelection(e.isControlDown()); |
160 |
|
|
161 |
} |
} |
162 |
public void mouseReleased(MouseEvent e) |
public void mouseReleased(MouseEvent e) |
163 |
{ |
{ |
216 |
table.addFocusListener(focusListener); |
table.addFocusListener(focusListener); |
217 |
table.addKeyListener(keyListener); |
table.addKeyListener(keyListener); |
218 |
table.addMouseListener(mouseInputListener); |
table.addMouseListener(mouseInputListener); |
219 |
|
table.addMouseMotionListener(mouseInputListener); |
220 |
} |
} |
221 |
|
|
222 |
protected void uninstallDefaults() |
protected void uninstallDefaults() |
248 |
table.removeFocusListener(focusListener); |
table.removeFocusListener(focusListener); |
249 |
table.removeKeyListener(keyListener); |
table.removeKeyListener(keyListener); |
250 |
table.removeMouseListener(mouseInputListener); |
table.removeMouseListener(mouseInputListener); |
251 |
|
table.removeMouseMotionListener(mouseInputListener); |
252 |
} |
} |
253 |
|
|
254 |
public void installUI(JComponent comp) |
public void installUI(JComponent comp) |