/** * ******************************************************************************* * * @return */ protected File getSelectedFile() { ListSelectionModel selectionModel = getSelectionModel(); int row = selectionModel.getAnchorSelectionIndex(); DirectoryTableModel tableModel = (DirectoryTableModel) getModel(); return tableModel.getFile(row); }
private void maybeGrabSelection() { if (table.getSelectedRow() != -1) { // Grab selection ListSelectionModel rowSel = table.getSelectionModel(); ListSelectionModel colSel = table.getColumnModel().getSelectionModel(); if (!haveAnchor()) { // System.err.println("Updating from table's selection"); setSelection( rowSel.getAnchorSelectionIndex(), rowSel.getLeadSelectionIndex(), colSel.getAnchorSelectionIndex(), colSel.getLeadSelectionIndex()); } else { // System.err.println("Updating lead from table's selection"); setSelection( getRowAnchor(), rowSel.getLeadSelectionIndex(), getColAnchor(), colSel.getLeadSelectionIndex()); } // printSelection(); } }
public void actionPerformed(ActionEvent e) { JListMutable list = (JListMutable) e.getSource(); if (!list.hasFocus()) { CellEditor cellEditor = list.getListCellEditor(); if (cellEditor != null && !cellEditor.stopCellEditing()) { return; } list.requestFocus(); return; } ListSelectionModel rsm = list.getSelectionModel(); int anchorRow = rsm.getAnchorSelectionIndex(); list.editCellAt(anchorRow, null); Component editorComp = list.getEditorComponent(); if (editorComp != null) { editorComp.requestFocus(); } }
public void actionPerformed(ActionEvent e) { JTable table = (JTable) e.getSource(); if (!table.hasFocus()) { CellEditor cellEditor = table.getCellEditor(); if (cellEditor != null && !cellEditor.stopCellEditing()) { return; } table.requestFocus(); return; } ListSelectionModel rsm = table.getSelectionModel(); int anchorRow = rsm.getAnchorSelectionIndex(); table.editCellAt(anchorRow, PropertySheetTableModel.VALUE_COLUMN); Component editorComp = table.getEditorComponent(); if (editorComp != null) { editorComp.requestFocus(); } }