本文整理汇总了Java中javax.swing.table.DefaultTableModel.fireTableDataChanged方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultTableModel.fireTableDataChanged方法的具体用法?Java DefaultTableModel.fireTableDataChanged怎么用?Java DefaultTableModel.fireTableDataChanged使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.table.DefaultTableModel
的用法示例。
在下文中一共展示了DefaultTableModel.fireTableDataChanged方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: refreshModel
import javax.swing.table.DefaultTableModel; //导入方法依赖的package包/类
private void refreshModel(final ProfilerTable table) {
Object selected = null;
Set original = new HashSet();
int selrow = table.getSelectedRow();
int column = table.convertColumnIndexToView(0);
for (int row = 0; row < table.getRowCount(); row++) {
Object value = table.getValueAt(row, column);
original.add(value);
if (row == selrow) selected = value;
}
final DefaultTableModel model = (DefaultTableModel)table.getModel();
Vector data = model.getDataVector();
data.clear();
for (JavaPlatform platform : JavaPlatform.getPlatforms()) {
data.add(new Vector(Arrays.asList(platform, null)));
if (!original.contains(platform)) selected = platform;
}
table.clearSelection();
model.fireTableDataChanged();
if (selected != null) table.selectValue(selected, column, true);
RequestProcessor.getDefault().post(new Runnable() {
public void run() { refreshTimes(model); }
});
}
示例2: Limpar_Campos_Tela
import javax.swing.table.DefaultTableModel; //导入方法依赖的package包/类
public static void Limpar_Campos_Tela(JPanel tela) {
for (Component componente : tela.getComponents()) {
if (componente instanceof JPanel) {
Limpar_Campos_Tela((JPanel) componente);
}
if (componente instanceof JTextField) {
((JTextField) componente).setText("");
}
if (componente instanceof JFormattedTextField) {
((JFormattedTextField) componente).setText("");
}
if(componente instanceof JScrollPane){
JViewport viewport = ((JScrollPane)componente).getViewport();
JTable table = (JTable)viewport.getView();
DefaultTableModel model = (DefaultTableModel) table.getModel();
model.getDataVector().removeAllElements();
model.fireTableDataChanged();
}
}
}
示例3: setDataToTable
import javax.swing.table.DefaultTableModel; //导入方法依赖的package包/类
private void setDataToTable(List<Eat> eats) {
DefaultTableModel df = (DefaultTableModel) jTable1.getModel();
df.getDataVector().removeAllElements();
df.fireTableDataChanged();
for (Eat eat : eats) {
List<String> foods = new ArrayList<>();
for (Food food : eat.getFoods()) {
foods.add(food.getFood());
}
Object[] row = new Object[]{
eat.getId(),
eat.getName(),
foods.toString()
};
df.addRow(row);
}
df.fireTableDataChanged();
}
示例4: openScheduleInTable
import javax.swing.table.DefaultTableModel; //导入方法依赖的package包/类
private void openScheduleInTable(ScheduleJTable table,DefaultTableModel data, Schedule schedule) {
if(schedule!=null) {
data.setDataVector(schedule.toStringArray(), selectedTrainColumnNames);
}
data.fireTableDataChanged();
table.schedule = schedule;
}
示例5: refreshTableModel
import javax.swing.table.DefaultTableModel; //导入方法依赖的package包/类
/**
* Refreshes the local table model by reloading the data from the DynForm.
*/
@SuppressWarnings("unchecked")
public void refreshTableModel() {
int rowIndexSelected = this.getSelectedRow();
DefaultTableModel dtm = (DefaultTableModel) this.getModel();
if (dtm.getColumnCount()==0) {
// --- Create a new table model ---------------
Vector<String> columnNames = new Vector<String>();
columnNames.add(" ");
columnNames.add(" ");
dtm = this.getTableModel();
dtm.setDataVector(this.getDataVector(), columnNames);
this.setModel(dtm);
this.setRendererAndEditors();
this.setRowSorter(this.getMyRowSorter());
} else {
// --- Exchange or re-new the data model ------
DynTableDataVector newDataVector = new DynTableDataVector(this.dynForm);
if (newDataVector.isEqualStructure(dtm.getDataVector())==false) {
// --- exchange data completely -----------
this.setDataVector(newDataVector);
dtm.getDataVector().removeAllElements();
dtm.getDataVector().addAll(this.getDataVector());
dtm.fireTableDataChanged();
this.setRowSorter(this.getMyRowSorter());
} else {
// --- Same structure! --------------------
// --- => Just exchange different values --
// // --- THIS IS JUST A BACKUP SOLUTION -----
// for (int i=0; i < this.getDataVector().size(); i++) {
//
// Object objectThisRow = this.getDataVector().get(i);
// Vector<Object> rowThis = (Vector<Object>) objectThisRow;
// DynType dynTypeThis = (DynType) rowThis.get(0);
// JComponent jCompThis = dynTypeThis.getFieldDisplay();
//
// Object objectNewRow = newDataVector.get(i);
// Vector<Object> rowNew = (Vector<Object>) objectNewRow;
// DynType dynTypeNew = (DynType) rowNew.get(0);
// JComponent jCompNew = dynTypeNew.getFieldDisplay();
//
// if ((jCompThis!=null && jCompNew!=null) && jCompThis.getClass().getName().equals(jCompNew.getClass().getName())==true) {
// if (jCompThis instanceof JTextField) {
// ((JTextField) jCompThis).setText(((JTextField) jCompNew).getText());
// } else if (jCompThis instanceof JCheckBox) {
// ((JCheckBox) jCompThis).setSelected(((JCheckBox) jCompNew).isSelected());
// }
// }
//
// }
dtm.fireTableDataChanged();
}
}
// --- Set new selection --------------------------
int rowCount = this.getRowCount();
if (rowIndexSelected>(rowCount-1)) {
this.setRowSelectionInterval(rowCount-1, rowCount-1);
} else if (rowIndexSelected>-1) {
this.setRowSelectionInterval(rowIndexSelected, rowIndexSelected);
}
}