本文整理匯總了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);
}