本文整理汇总了Java中javax.swing.table.TableModel.setValueAt方法的典型用法代码示例。如果您正苦于以下问题:Java TableModel.setValueAt方法的具体用法?Java TableModel.setValueAt怎么用?Java TableModel.setValueAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.table.TableModel
的用法示例。
在下文中一共展示了TableModel.setValueAt方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mouseClicked
import javax.swing.table.TableModel; //导入方法依赖的package包/类
@Override
public void mouseClicked(MouseEvent e) {
JTableHeader header = (JTableHeader) e.getSource();
JTable table = header.getTable();
TableColumnModel columnModel = table.getColumnModel();
int vci = columnModel.getColumnIndexAtX(e.getX());
int mci = table.convertColumnIndexToModel(vci);
if (mci == targetColumnIndex) {
if (SwingUtilities.isLeftMouseButton(e)) {
TableColumn column = columnModel.getColumn(vci);
Object v = column.getHeaderValue();
boolean b = Status.DESELECTED.equals(v);
TableModel m = table.getModel();
for (int i = 0; i < m.getRowCount(); i++) {
m.setValueAt(b, i, mci);
}
column.setHeaderValue(b ? Status.SELECTED : Status.DESELECTED);
} else if (SwingUtilities.isRightMouseButton(e)) {
if (popupMenu != null) {
popupMenu.show(table, e.getX(), 0);
}
}
}
}
示例2: restoreDefaultsButtonActionPerformed
import javax.swing.table.TableModel; //导入方法依赖的package包/类
/**
* reverts the selected state of all the detectors to their defaults as specified in the findbugs.xml file
*
* @param evt the swing event corresponding to the mouse click of the Restore Defaults button
*/
private void restoreDefaultsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_restoreDefaultsButtonActionPerformed
Iterator<DetectorFactory> i = DetectorFactoryCollection.instance().factoryIterator();
DefaultSortedTableModel sorter = (DefaultSortedTableModel) detectorTable.getModel();
TableModel model = sorter.getBaseTableModel();
int row = 0;
while (i.hasNext()) {
DetectorFactory factory = i.next();
model.setValueAt(factory.isDefaultEnabled() ? Boolean.TRUE : Boolean.FALSE, row++, ENABLED_COLUMN);
}
}
示例3: setValueAt
import javax.swing.table.TableModel; //导入方法依赖的package包/类
public void setValueAt(int y, int x, boolean val){
JTableOperator table = new JTableOperator(this, 0);
JTable t = ((JTable)table.getSource());
TableModel model = t.getModel();
model.setValueAt(val, y, x);
}
示例4: selectProjectByIndex
import javax.swing.table.TableModel; //导入方法依赖的package包/类
protected static void selectProjectByIndex(TableModel model, int index) {
model.setValueAt(true, index, 0);
}