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