javax.swing.JTable.isCellSelected()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(135)

本文整理了Java中javax.swing.JTable.isCellSelected()方法的一些代码示例,展示了JTable.isCellSelected()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTable.isCellSelected()方法的具体详情如下:
包路径:javax.swing.JTable
类名称:JTable
方法名:isCellSelected

JTable.isCellSelected介绍

暂无

代码示例

代码示例来源:origin: jpcsp/jpcsp

private boolean isCellChecked(JTable table) {
  for (int i = 0; i < table.getRowCount(); i++) {
    if (table.isCellSelected(i, 1)) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: joel-costigliola/assertj-swing

@RunsInCurrentThread
static boolean isCellSelected(final @Nonnull JTable table, final int row, final int column) {
 return table.isCellSelected(row, column);
}

代码示例来源:origin: UISpec4J/UISpec4J

public Component getSwingRendererComponentAt(int row, int column) {
 return jTable
  .getCellRenderer(row, column)
  .getTableCellRendererComponent(jTable,
                  jTable.getValueAt(row, column),
                  jTable.isCellSelected(row, column),
                  false,
                  row, column);
}

代码示例来源:origin: UISpec4J/UISpec4J

private void assertCellPropertyEquals(Object[][] properties, ComponentPropertyAccessor accessor) {
 AssertAdapter.assertEquals(properties.length, jTable.getRowCount());
 for (int row = 0; row < properties.length; row++) {
  for (int col = 0; col < properties[row].length; col++) {
   TableCellRenderer cellRenderer = jTable.getCellRenderer(row, col);
   Component component =
    cellRenderer.getTableCellRendererComponent(jTable,
                          jTable.getModel().getValueAt(row, col),
                          jTable.isCellSelected(row, col), false, row, col);
   AssertAdapter.assertEquals("Error at (" + row + ", " + col + ")",
                 properties[row][col], accessor.getProperty(component));
  }
 }
}

代码示例来源:origin: net.sf.jt400/jt400

public void actionPerformed(ActionEvent e)
 {
  if(e.getSource() == table_)
  {
   StringBuffer textToCopy = new StringBuffer();
   int[] rows = table_.getSelectedRows();
   int[] columns = table_.getSelectedColumns();
   for (int i=0; i<rows.length; ++i)
   {
    for (int j=0; j<columns.length; ++j)
    {
     if (table_.isCellSelected(rows[i], columns[j]))
     {
      textToCopy.append(table_.getValueAt(rows[i], columns[j]));
      textToCopy.append('\t');
     }
    }
    textToCopy.append('\n');
   }
   StringSelection dataToTransfer = new StringSelection(textToCopy.toString());
   Toolkit.getDefaultToolkit().getSystemClipboard().setContents(dataToTransfer, dataToTransfer);
  }
  else
  {
   Trace.log(Trace.WARNING, "Copy action received from unknown source: "+e.getSource());
  }
 }
};

代码示例来源:origin: UISpec4J/UISpec4J

public void check() {
  if (!jTable.getCellSelectionEnabled()) {
   AssertAdapter.fail("Cell-level selection is not supported on this table");
  }
  AssertAdapter.assertTrue(jTable.isCellSelected(rowIndex, columnIndex));
 }
};

代码示例来源:origin: com.jidesoft/jide-oss

/**
 * Selects the cell at the specified row and column index. If incremental is true, the previous selection will not
 * be cleared. This method will use {@link JTable#changeSelection(int,int,boolean,boolean)} method to select the
 * cell if the row and column index is in the range and the cell was not selected. The last two parameters of
 * changeSelection is true and false respectively.
 *
 * @param table       the table
 * @param rowIndex    the row index of the cell.
 * @param columnIndex the column index of the cell
 * @param incremental false to clear all previous selection. True to keep the previous selection.
 */
protected void addTableSelection(JTable table, int rowIndex, int columnIndex, boolean incremental) {
  if (!incremental)
    table.clearSelection();
  if (rowIndex >= 0 && columnIndex >= 0 && rowIndex < table.getRowCount() && columnIndex < table.getColumnCount()
      && !table.isCellSelected(rowIndex, columnIndex)) {
    table.changeSelection(rowIndex, columnIndex, true, false);
  }
}

代码示例来源:origin: stackoverflow.com

if (table.isCellSelected(r, c)) {

代码示例来源:origin: org.fudaa.framework.ebli/ebli-common

private void remove() {
 final ListSelectionModel colModel = table_.getColumnModel().getSelectionModel();
 final ListSelectionModel rowModel = table_.getSelectionModel();
 final int minRow = rowModel.getMinSelectionIndex();
 final int maxRow = rowModel.getMaxSelectionIndex();
 if (!colModel.isSelectionEmpty()) {
  final List idx = new ArrayList();
  final int max = colModel.getMaxSelectionIndex();
  for (int col = colModel.getMinSelectionIndex(); col <= max; col++) {
   if (colModel.isSelectedIndex(col)) {
    for (int rowIdx = minRow; rowIdx <= maxRow; rowIdx++) {
     if (table_.isCellSelected(rowIdx, col)) {
      final Object o = model_.getValueAt(rowIdx, col);
      if (o != null) {
       idx.add(o);
      }
     }
    }
   }
  }
  if (idx.size() > 0) {
   model_.remove(idx);
  }
 }
}

代码示例来源:origin: UISpec4J/UISpec4J

public void check() {
  int rowCount = expected.length;
  int columnCount = expected[0].length;
  Boolean[][] actual = new Boolean[rowCount][columnCount];
  if (jTable.getCellSelectionEnabled()) {
   for (int row = 0; row < rowCount; row++) {
    for (int column = 0; column < columnCount; column++) {
     actual[row][column] = jTable.isCellSelected(row, column);
    }
   }
  }
  else {
   for (int row = 0; row < rowCount; row++) {
    boolean isRowSelected = jTable.isRowSelected(row);
    for (int column = 0; column < columnCount; column++) {
     actual[row][column] = isRowSelected;
    }
   }
  }
  ArrayUtils.orderedCompare(ArrayUtils.toBooleanObjects(expected), actual);
 }
};

代码示例来源:origin: stackoverflow.com

public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
  Component c = super.prepareRenderer(renderer, row, column);
  if (isCellSelected(row, column) == false) {
    c.setBackground(colorForRow(row));
    c.setForeground(UIManager.getColor("Table.foreground"));

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/toniclf

int   column=table.columnAtPoint(p);
if((column!=-1) && (row!=-1)
      && table.isCellSelected(row, column))

代码示例来源:origin: stackoverflow.com

c.setBackground(Color.RED);
else {
 if (rowIndex % 2 == 0 && !isCellSelected(rowIndex, vColIndex)) {
  c.setBackground(Color.YELLOW);
 } else {

代码示例来源:origin: stackoverflow.com

finalTable.setRowSelectionAllowed(true);
if (finalTable.isCellSelected(finalTable.getSelectedRow(), 0)) {
  finalTable.setColumnSelectionAllowed(false);
  finalTable.setRowSelectionAllowed(true);

代码示例来源:origin: com.github.insubstantial/substance

isSelected = this.selectedIndices.containsKey(cellId);
else {
  isSelected = this.table.isCellSelected(row, column);

代码示例来源:origin: org.java.net.substance/substance

isSelected = this.selectedIndices.containsKey(cellId);
else {
  isSelected = this.table.isCellSelected(row, column);

代码示例来源:origin: org.java.net.substance/substance

for (int i = 0; i < rows; i++) {
  for (int j = 0; j < cols; j++) {
    if (this.table.isCellSelected(i, j)) {
      TableCellId cellId = new TableCellId(i, j);
      this.selectedIndices.put(cellId, this.table

代码示例来源:origin: com.github.insubstantial/substance

for (int j = 0; j < cols; j++) {
  TableCellId cellId = new TableCellId(i, j);
  if (this.table.isCellSelected(i, j)) {

代码示例来源:origin: com.github.insubstantial/substance

for (int i = 0; i < rows; i++) {
  for (int j = 0; j < cols; j++) {
    if (this.table.isCellSelected(i, j)) {
      TableCellId cellId = new TableCellId(i, j);
      this.selectedIndices.put(cellId,

代码示例来源:origin: stackoverflow.com

int anchorCol = csm.getAnchorSelectionIndex();
boolean anchorSelected = isCellSelected(anchorRow, anchorCol);

相关文章

JTable类方法