@@ -133,9 +133,10 @@ public void propertyChange(PropertyChangeEvent e) {
133133 case "rowSorter" :
134134 case "sorter" :
135135 case "autoResizeMode" :
136- case "model" :
136+ // case "model":
137137 return ;
138138 }
139+ System .out .println ("JTableUI property not handled: " + prop );
139140 super .propertyChange (e );
140141 }
141142
@@ -1260,30 +1261,30 @@ private void mousePressedDND(MouseEvent e) {
12601261 boolean grabFocus = true ;
12611262 dragStarted = false ;
12621263
1263- // if (canStartDrag() && DragRecognitionSupport.mousePressed(e)) {
1264- //
1265- // dragPressDidSelection = false;
1266- //
1267- // if (e.isControlDown() && isFileList) {
1268- // // do nothing for control - will be handled on release
1269- // // or when drag starts
1270- // return;
1271- // } else if (!e.isShiftDown() && table.isCellSelected(pressedRow, pressedCol)) {
1272- // // clicking on something that's already selected
1273- // // and need to make it the lead now
1274- // table.getSelectionModel().addSelectionInterval(pressedRow,
1275- // pressedRow);
1276- // table.getColumnModel().getSelectionModel().
1277- // addSelectionInterval(pressedCol, pressedCol);
1278- //
1279- // return;
1280- // }
1281- //
1282- // dragPressDidSelection = true;
1283- //
1284- // // could be a drag initiating event - don't grab focus
1285- // grabFocus = false;
1286- // } else
1264+ if (canStartDrag ()) { // && DragRecognitionSupport.mousePressed(e)) {
1265+
1266+ dragPressDidSelection = false ;
1267+
1268+ if (e .isControlDown () && isFileList ) {
1269+ // do nothing for control - will be handled on release
1270+ // or when drag starts
1271+ return ;
1272+ } else if (!e .isShiftDown () && table .isCellSelected (pressedRow , pressedCol )) {
1273+ // clicking on something that's already selected
1274+ // and need to make it the lead now
1275+ table .getSelectionModel ().addSelectionInterval (pressedRow ,
1276+ pressedRow );
1277+ table .getColumnModel ().getSelectionModel ().
1278+ addSelectionInterval (pressedCol , pressedCol );
1279+
1280+ return ;
1281+ }
1282+
1283+ dragPressDidSelection = true ;
1284+
1285+ // could be a drag initiating event - don't grab focus
1286+ grabFocus = false ;
1287+ } else
12871288
12881289 if (!isFileList ) {
12891290 // When drag can't happen, mouse drags might change the selection in the table
@@ -1384,39 +1385,40 @@ public void mouseReleased(MouseEvent e) {
13841385 }
13851386
13861387 private void mouseReleasedDND (MouseEvent e ) {
1387- // MouseEvent me = DragRecognitionSupport.mouseReleased(e);
1388- // if (me != null) {
1389- // SwingUtilities2.adjustFocus(table);
1390- // if (!dragPressDidSelection) {
1391- // adjustSelection(me);
1392- // }
1393- // }
1394- //
1395- // if (!dragStarted) {
1396- // if (isFileList) {
1397- // maybeStartTimer();
1398- // return;
1399- // }
1400- //
1401- // Point p = e.getPoint();
1402- //
1403- // if (pressedEvent != null &&
1404- // table.rowAtPoint(p) == pressedRow &&
1405- // table.columnAtPoint(p) == pressedCol &&
1406- // table.editCellAt(pressedRow, pressedCol, pressedEvent)) {
1407- //
1408- // setDispatchComponent(pressedEvent);
1409- // repostEvent(pressedEvent);
1410- //
1411- // // This may appear completely odd, but must be done for backward
1412- // // compatibility reasons. Developers have been known to rely on
1413- // // a call to shouldSelectCell after editing has begun.
1414- // CellEditor ce = table.getCellEditor();
1415- // if (ce != null) {
1416- // ce.shouldSelectCell(pressedEvent);
1417- // }
1418- // }
1419- // }
1388+ MouseEvent me = e ;//DragRecognitionSupport.mouseReleased(e);
1389+ if (me != null ) {
1390+ SwingUtilities2 .adjustFocus (table );
1391+ if (!dragPressDidSelection ) {
1392+ adjustSelection (me );
1393+ }
1394+ }
1395+
1396+ if (!dragStarted ) {
1397+ if (isFileList ) {
1398+ maybeStartTimer ();
1399+ return ;
1400+ }
1401+
1402+ Point p = e .getPoint ();
1403+
1404+ if (pressedEvent != null &&
1405+ table .rowAtPoint (p ) == pressedRow &&
1406+ table .columnAtPoint (p ) == pressedCol &&
1407+ table .editCellAt (pressedRow , pressedCol , pressedEvent )) {
1408+
1409+ setDispatchComponent (pressedEvent );
1410+ repostEvent (pressedEvent );
1411+
1412+ // This may appear completely odd, but must be done for backward
1413+ // compatibility reasons. Developers have been known to rely on
1414+ // a call to shouldSelectCell after editing has begun.
1415+ CellEditor ce = table .getCellEditor ();
1416+ if (ce != null ) {
1417+ ce .shouldSelectCell (pressedEvent );
1418+ }
1419+ }
1420+ }
1421+ repaintTable ();
14201422 }
14211423
14221424 public void mouseEntered (MouseEvent e ) {}
@@ -1442,12 +1444,14 @@ public void mouseDragged(MouseEvent e) {
14421444 if (SwingUtilities2 .shouldIgnore (e , table )) {
14431445 return ;
14441446 }
1445- //
1446- // if (table.getDragEnabled() &&
1447- // (DragRecognitionSupport.mouseDragged(e, this) || dragStarted)) {
1448- //
1449- // return;
1450- // }
1447+
1448+ if (table .getDragEnabled ()
1449+ // && (DragRecognitionSupport.mouseDragged(e, this) ||
1450+ // dragStarted)
1451+ ) {
1452+
1453+ return ;
1454+ }
14511455
14521456 repostEvent (e );
14531457
@@ -1488,7 +1492,8 @@ public void propertyChange(PropertyChangeEvent event) {
14881492 header .setComponentOrientation (
14891493 (ComponentOrientation )event .getNewValue ());
14901494 }
1491- // } else if ("dropLocation" == changeName) {
1495+ } else if ("dropLocation" == changeName ) {
1496+ repaintTable ();
14921497// JTable.DropLocation oldValue = (JTable.DropLocation)event.getOldValue();
14931498// repaintDropLocation(oldValue);
14941499// repaintDropLocation(table.getDropLocation());
@@ -2275,57 +2280,59 @@ private void paintCells(Graphics g, int rMin, int rMax, int cMin, int cMax) {
22752280 }
22762281
22772282 private void paintDraggedArea (Graphics g , int rMin , int rMax , TableColumn draggedColumn , int distance ) {
2278- int draggedColumnIndex = viewIndexForColumn (draggedColumn );
2279-
2280- Rectangle minCell = table .getCellRect (rMin , draggedColumnIndex , true );
2281- Rectangle maxCell = table .getCellRect (rMax , draggedColumnIndex , true );
2282-
2283- Rectangle vacatedColumnRect = minCell .union (maxCell );
2284-
2285- // Paint a gray well in place of the moving column.
2286- g .setColor (table .getParent ().getBackground ());
2287- g .fillRect (vacatedColumnRect .x , vacatedColumnRect .y ,
2288- vacatedColumnRect .width , vacatedColumnRect .height );
2289-
2290- // Move to the where the cell has been dragged.
2291- vacatedColumnRect .x += distance ;
2292-
2293- // Fill the background.
2294- g .setColor (table .getBackground ());
2295- g .fillRect (vacatedColumnRect .x , vacatedColumnRect .y ,
2296- vacatedColumnRect .width , vacatedColumnRect .height );
2297-
2298- // Paint the vertical grid lines if necessary.
2299- if (table .getShowVerticalLines ()) {
2300- g .setColor (table .getGridColor ());
2301- int x1 = vacatedColumnRect .x ;
2302- int y1 = vacatedColumnRect .y ;
2303- int x2 = x1 + vacatedColumnRect .width - 1 ;
2304- int y2 = y1 + vacatedColumnRect .height - 1 ;
2305- // Left
2306- g .drawLine (x1 -1 , y1 , x1 -1 , y2 );
2307- // Right
2308- g .drawLine (x2 , y1 , x2 , y2 );
2309- }
2310-
2311- for (int row = rMin ; row <= rMax ; row ++) {
2312- // Render the cell value
2313- Rectangle r = table .getCellRect (row , draggedColumnIndex , false );
2314- r .x += distance ;
2315- paintCell (g , r , row , draggedColumnIndex );
2316-
2317- // Paint the (lower) horizontal grid line if necessary.
2318- if (table .getShowHorizontalLines ()) {
2319- g .setColor (table .getGridColor ());
2320- Rectangle rcr = table .getCellRect (row , draggedColumnIndex , true );
2321- rcr .x += distance ;
2322- int x1 = rcr .x ;
2323- int y1 = rcr .y ;
2324- int x2 = x1 + rcr .width - 1 ;
2325- int y2 = y1 + rcr .height - 1 ;
2326- g .drawLine (x1 , y2 , x2 , y2 );
2327- }
2328- }
2283+ setTainted ();
2284+ setHTMLElement ();
2285+ // int draggedColumnIndex = viewIndexForColumn(draggedColumn);
2286+ //
2287+ // Rectangle minCell = table.getCellRect(rMin, draggedColumnIndex, true);
2288+ // Rectangle maxCell = table.getCellRect(rMax, draggedColumnIndex, true);
2289+ //
2290+ // Rectangle vacatedColumnRect = minCell.union(maxCell);
2291+ //
2292+ // // Paint a gray well in place of the moving column.
2293+ // g.setColor(table.getParent().getBackground());
2294+ // g.fillRect(vacatedColumnRect.x, vacatedColumnRect.y,
2295+ // vacatedColumnRect.width, vacatedColumnRect.height);
2296+ //
2297+ // // Move to the where the cell has been dragged.
2298+ // vacatedColumnRect.x += distance;
2299+ //
2300+ // // Fill the background.
2301+ // g.setColor(table.getBackground());
2302+ // g.fillRect(vacatedColumnRect.x, vacatedColumnRect.y,
2303+ // vacatedColumnRect.width, vacatedColumnRect.height);
2304+ //
2305+ // // Paint the vertical grid lines if necessary.
2306+ // if (table.getShowVerticalLines()) {
2307+ // g.setColor(table.getGridColor());
2308+ // int x1 = vacatedColumnRect.x;
2309+ // int y1 = vacatedColumnRect.y;
2310+ // int x2 = x1 + vacatedColumnRect.width - 1;
2311+ // int y2 = y1 + vacatedColumnRect.height - 1;
2312+ // // Left
2313+ // g.drawLine(x1-1, y1, x1-1, y2);
2314+ // // Right
2315+ // g.drawLine(x2, y1, x2, y2);
2316+ // }
2317+ //
2318+ // for(int row = rMin; row <= rMax; row++) {
2319+ // // Render the cell value
2320+ // Rectangle r = table.getCellRect(row, draggedColumnIndex, false);
2321+ // r.x += distance;
2322+ // paintCell(g, r, row, draggedColumnIndex);
2323+ //
2324+ // // Paint the (lower) horizontal grid line if necessary.
2325+ // if (table.getShowHorizontalLines()) {
2326+ // g.setColor(table.getGridColor());
2327+ // Rectangle rcr = table.getCellRect(row, draggedColumnIndex, true);
2328+ // rcr.x += distance;
2329+ // int x1 = rcr.x;
2330+ // int y1 = rcr.y;
2331+ // int x2 = x1 + rcr.width - 1;
2332+ // int y2 = y1 + rcr.height - 1;
2333+ // g.drawLine(x1, y2, x2, y2);
2334+ // }
2335+ // }
23292336 }
23302337
23312338 private void paintCell (Graphics g , Rectangle cellRect , int row , int column ) {
@@ -2440,5 +2447,10 @@ private static int getAdjustedLead(JTable table, boolean row) {
24402447//
24412448
24422449
2450+ public void repaintTable () {
2451+ setTainted ();
2452+ setHTMLElement ();
2453+ }
2454+
24432455
24442456}
0 commit comments