table.getColumnModel().getSelectionModel().addListSelectionListener(selectionListener); allPane.setTopComponent(new JScrollPane(table)); messageTextArea = new JTextArea();
@Override public void mousePressed(MouseEvent e) { PanelTable.this.tableValues.requestFocusInWindow(); if (SwingUtilities.isRightMouseButton(e)) { /** * Keep selection when multiple cells are selected, * move focus only */ Point p = e.getPoint(); int rowNumber = PanelTable.this.tableValues.rowAtPoint(p); int colNumber = PanelTable.this.tableValues.columnAtPoint(p); DefaultListSelectionModel modelRow = (DefaultListSelectionModel) PanelTable.this.tableValues .getSelectionModel(); DefaultListSelectionModel modelColumn = (DefaultListSelectionModel) PanelTable.this.tableValues .getColumnModel().getSelectionModel(); modelRow.moveLeadSelectionIndex(rowNumber); modelColumn.moveLeadSelectionIndex(colNumber); } } });
@Override public void mousePressed(MouseEvent e) { PanelConsoles.this.networkTable.requestFocusInWindow(); // move selected row and place cursor on focused cell if (SwingUtilities.isRightMouseButton(e)) { Point p = e.getPoint(); // get the row index that contains that coordinate int rowNumber = PanelConsoles.this.networkTable.rowAtPoint(p); int colNumber = PanelConsoles.this.networkTable.columnAtPoint(p); // Get the ListSelectionModel of the JTable DefaultListSelectionModel model = (DefaultListSelectionModel) PanelConsoles.this.networkTable.getSelectionModel(); DefaultListSelectionModel model2 = (DefaultListSelectionModel) PanelConsoles.this.networkTable.getColumnModel().getSelectionModel(); PanelConsoles.this.networkTable.setRowSelectionInterval(rowNumber, rowNumber); model.moveLeadSelectionIndex(rowNumber); model2.moveLeadSelectionIndex(colNumber); } } });
/** * Sets the col-selection for an array of columns. * @param cols the columns */ public void setSelectedColumns(int[] cols) { columnModel.getSelectionModel().clearSelection(); if (cols != null) { for (int i=0; i < cols.length; i++) { columnModel.getSelectionModel().addSelectionInterval(cols[i], cols[i]); } } }
/** * Sets the selected column. * (getSelectedColumn is implemented in JTable but not setSelectedColumn, for whatever reason) * @param col the column number */ public void setSelectedColumn(int col) { columnModel.getSelectionModel().setSelectionInterval(col, col); }
private void setupDataTable() { JTable table = this.table.getTable(); table.getModel().addTableModelListener(tableListener); table.getSelectionModel().addListSelectionListener( tableSelectionListener); table.getColumnModel().getSelectionModel() .addListSelectionListener(tableSelectionListener); }
@Override protected Point getFocusedCell() { int leadRow = component.getSelectionModel().getLeadSelectionIndex(); int leadColumn = component.getColumnModel().getSelectionModel() .getLeadSelectionIndex(); return new Point(leadColumn, leadRow); }
@Override protected Point getFocusedCell() { int leadRow = component.getSelectionModel().getLeadSelectionIndex(); int leadColumn = component.getColumnModel().getSelectionModel() .getLeadSelectionIndex(); return new Point(leadColumn, leadRow); }
@Override protected Point getFocusedCell() { int leadRow = component.getSelectionModel().getLeadSelectionIndex(); int leadColumn = component.getColumnModel().getSelectionModel() .getLeadSelectionIndex(); return new Point(leadColumn, leadRow); }
@Override protected Point getFocusedCell() { int leadRow = component.getSelectionModel() .getLeadSelectionIndex(); int leadColumn = component.getColumnModel().getSelectionModel() .getLeadSelectionIndex(); return new Point(leadColumn, leadRow); }
private void setValueIsAdjusting(boolean flag) { table.getSelectionModel().setValueIsAdjusting(flag); table.getColumnModel().getSelectionModel().setValueIsAdjusting(flag); }
public void focusLost(FocusEvent evt) { if (evt.isTemporary()) { return; } int selectedRow = list.getSelectedIndex(); table.getSelectionModel().setAnchorSelectionIndex(selectedRow); table.getColumnModel().getSelectionModel().setAnchorSelectionIndex(0); }
public void focusLost(FocusEvent evt) { if (evt.isTemporary()) return; int selectedRow = list.getSelectedIndex(); table.getSelectionModel().setAnchorSelectionIndex(selectedRow); table.getColumnModel().getSelectionModel().setAnchorSelectionIndex(0); }
/** * Возращает колонку содержащую фокус * @return колонка с фокусом */ public int getFocusedColumn(){ return getColumnModel().getSelectionModel().getLeadSelectionIndex(); }
public void run() { final JTable table = getTable(); table.getSelectionModel().setLeadSelectionIndex(row); table.getColumnModel().getSelectionModel().setLeadSelectionIndex(column); table.requestFocus(); } });
private void displaySearchResult(int row, int column) { quickSearchLastRow = row; quickSearchLastColumn = column; table.getSelectionModel().setSelectionInterval(row, row); table.getColumnModel().getSelectionModel().setSelectionInterval(column, column); table.scrollRectToVisible(table.getCellRect(row, column, true)); }
public void valueChanged(final ListSelectionEvent _e) { final ListSelectionModel rowModel = table_.getSelectionModel(); if (rowModel.isSelectionEmpty()) { ch_.setColor(null); } final int row = rowModel.getLeadSelectionIndex(); final int col = table_.getColumnModel().getSelectionModel().getLeadSelectionIndex(); final Color c = model_.getColor(row, col); ch_.setColor(c); }
/** * {@inheritDoc} */ @Override public boolean hasFocus() { boolean rowIsLead = (table.getSelectionModel() .getLeadSelectionIndex() == row); boolean colIsLead = (table.getColumnModel().getSelectionModel() .getLeadSelectionIndex() == column); return table.isFocusOwner() && (rowIsLead && colIsLead); }
/** * {@inheritDoc} */ @Override public boolean hasFocus() { boolean rowIsLead = (table.getSelectionModel() .getLeadSelectionIndex() == row); boolean colIsLead = (table.getColumnModel().getSelectionModel() .getLeadSelectionIndex() == column); return table.isFocusOwner() && (rowIsLead && colIsLead); }
/** * {@inheritDoc} */ @Override public boolean hasFocus() { boolean rowIsLead = (table.getSelectionModel() .getLeadSelectionIndex() == row); boolean colIsLead = (table.getColumnModel().getSelectionModel() .getLeadSelectionIndex() == column); return table.isFocusOwner() && (rowIsLead && colIsLead); }