public void actionPerformed(ActionEvent e) { JGrid grid = (JGrid) e.getSource(); SelectionModel sm = grid.getSelectionModel(); anchorRow = sm.getAnchorRow(); leadRow = sm.getLeadRow(); anchorColumn = sm.getAnchorColumn(); leadColumn = sm.getLeadColumn(); int oldAnchorRow = anchorRow; int oldAnchorColumn = anchorColumn; if (grid.isEditing() && !grid.getCurrentCellEditor().stopCellEditing()) { return; } if (!inSelection) { moveWithinGridRange(grid, dx, dy, extend); if (!extend) { grid.changeSelection(anchorRow, anchorColumn, false, extend); } else { grid.changeSelection(leadRow, leadColumn, false, extend); } } else { if (moveWithinSelectedRange(grid, dx, dy, false)) { grid.changeSelection(anchorRow, anchorColumn, true, true); } else { grid.changeSelection(anchorRow, anchorColumn, false, false); } } }
public void actionPerformed(ActionEvent e) { JGrid grid = (JGrid) e.getSource(); if (!grid.hasFocus()) { CellEditor cellEditor = grid.getCurrentCellEditor(); if (cellEditor != null && !cellEditor.stopCellEditing()) { return; } grid.requestFocus(); } SelectionModel selectionModel = grid.getSelectionModel(); int anchorRow = selectionModel.getAnchorRow(); int anchorColumn = selectionModel.getAnchorColumn(); grid.editCellAt(anchorRow, anchorColumn, null); Component editorComp = grid.getEditorComponent(); if (editorComp != null) { editorComp.requestFocus(); } }