本文整理匯總了Java中javax.swing.event.TableModelEvent.UPDATE屬性的典型用法代碼示例。如果您正苦於以下問題:Java TableModelEvent.UPDATE屬性的具體用法?Java TableModelEvent.UPDATE怎麽用?Java TableModelEvent.UPDATE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類javax.swing.event.TableModelEvent
的用法示例。
在下文中一共展示了TableModelEvent.UPDATE屬性的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: tableChanged
public void tableChanged(TableModelEvent e) {
Object blank = "";
if(e.getType() == TableModelEvent.UPDATE) {
if(e.getColumn() == TableModelEvent.ALL_COLUMNS) {
;
}
else if(e.getFirstRow() == TableModelEvent.HEADER_ROW) {
;
}
else {
if(e.getFirstRow() == numRows-1) {
if(getValueAt(e.getFirstRow(), e.getColumn()).equals(blank) == false) {
addEmptyRow();
}
}
}
}
else if(e.getType() == TableModelEvent.DELETE) {
}
}
示例2: tableChanged
public void tableChanged(TableModelEvent e) {
// If a row changed and is a complete entry(both x and y values)
// plot the points on the display.
if(e.getType() == TableModelEvent.UPDATE) {
Object blank = "";
if(e.getFirstRow() != TableModelEvent.HEADER_ROW) {
if(tableModel.getValueAt(e.getFirstRow(), 0).equals(blank) == false &&
tableModel.getValueAt(e.getFirstRow(), 1).equals(blank) == false) {
updateAction.actionPerformed();
}
}
}
// If a row is removed, remove it from the display.
else if(e.getType() == TableModelEvent.DELETE) {
updateAction.actionPerformed();
}
}
示例3: tableModelEventToString
private static String tableModelEventToString (TableModelEvent e) {
StringBuilder sb = new StringBuilder();
sb.append ("TableModelEvent ");
switch (e.getType()) {
case TableModelEvent.INSERT : sb.append ("insert ");
break;
case TableModelEvent.DELETE : sb.append ("delete ");
break;
case TableModelEvent.UPDATE : sb.append ("update ");
break;
default : sb.append("Unknown type ").append(e.getType());
}
sb.append ("from ");
switch (e.getFirstRow()) {
case TableModelEvent.HEADER_ROW : sb.append ("header row ");
break;
default : sb.append (e.getFirstRow());
sb.append (' ');
}
sb.append ("to ");
sb.append (e.getLastRow());
sb.append (" column ");
switch (e.getColumn()) {
case TableModelEvent.ALL_COLUMNS :
sb.append ("ALL_COLUMNS");
break;
default : sb.append (e.getColumn());
}
return sb.toString();
}
示例4: tableChanged
/**
* Overridden for efficiency reasons (provides a better calculation of the
* dirty region). See
* <a href="http://www.objectdefinitions.com/odblog/2009/jtable-setrowheight-causes-slow-repainting/">this page</a>
* for a more complete discussion.
*/
@Override
public void tableChanged(TableModelEvent e) {
//if just an update, and not a data or structure changed event or an insert or delete, use the fixed row update handling
//otherwise call super.tableChanged to let the standard JTable update handling manage it
if ( e != null &&
e.getType() == TableModelEvent.UPDATE &&
e.getFirstRow() != TableModelEvent.HEADER_ROW &&
e.getLastRow() != Integer.MAX_VALUE) {
handleRowUpdate(e);
} else {
super.tableChanged(e);
}
}
示例5: tableChanged
@Override
public void tableChanged(TableModelEvent e) {
if (e.getType() == TableModelEvent.UPDATE && e.getColumn() == 0) {
int mci = 0;
int vci = table.convertColumnIndexToView(mci);
TableColumn column = table.getColumnModel().getColumn(vci);
Object title = column.getHeaderValue();
if (!Status.INDETERMINATE.equals(title)) {
column.setHeaderValue(Status.INDETERMINATE);
} else {
int selected = 0, deselected = 0;
TableModel m = table.getModel();
for (int i = 0; i < m.getRowCount(); i++) {
if (Boolean.TRUE.equals(m.getValueAt(i, mci))) {
selected++;
} else {
deselected++;
}
}
if (selected == 0) {
column.setHeaderValue(Status.DESELECTED);
} else if (deselected == 0) {
column.setHeaderValue(Status.SELECTED);
} else {
return;
}
}
table.getTableHeader().repaint();
}
}
示例6: tableChanged
public void tableChanged(TableModelEvent evt) {
if (evt.getType() == TableModelEvent.UPDATE) {
validateTable(evt.getFirstRow(), evt.getColumn());
}
}
示例7: SortingSafeTableModelEvent
public SortingSafeTableModelEvent(TableModel source,
int row,
int column) {
super(source, row, row, column, TableModelEvent.UPDATE);
}
示例8: tableChanged
@Override
public void tableChanged(TableModelEvent tme) {
if(tme.getSource()==this && tme.getFirstRow()>=0){
if(tme.getType()==TableModelEvent.UPDATE){
// --- Update Events in the table ---------
if(tme.getColumn() > 0){
// --- A single value was edited ------------------------------------
int seriesIndex = tme.getColumn()-1; // First column contains the time stamps.
int rowIndex = tme.getFirstRow();
Number key = (Number) this.getValueAt(rowIndex, 0);
Number value = (Number) this.getValueAt(rowIndex, tme.getColumn());
Vector<Number> rowVector = this.getRow(rowIndex);
try {
if(value!=null){
// --- Update new entry in chart and ontology model ---------
this.getChartModel().addOrUpdateValuePair(seriesIndex, key, value);
this.getOntologyModel().addOrUpdateValuePair(seriesIndex, key, value);
} else {
if (this.isEmptyTableModelRow(rowVector)==false) {
// --- Rewrite the data row -----------------------------
for (int i=1; i < rowVector.size(); i++) {
Number seriesValue = (Number) rowVector.get(i);
int series = i-1;
if (seriesValue!=null) {
this.getChartModel().addOrUpdateValuePair(series, key, seriesValue);
this.getOntologyModel().addOrUpdateValuePair(series, key, seriesValue);
} else {
this.getChartModel().removeValuePair(series, key);
this.getOntologyModel().removeValuePair(series, key);
}
} // end for
} else {
// --- Empty row, delete ValuePair ----------------------
this.getChartModel().removeValuePair(seriesIndex, key);
this.getOntologyModel().removeValuePair(seriesIndex, key);
}
}
} catch (NoSuchSeriesException e) {
System.err.println("Error updating data model: Series "+seriesIndex+" does mot exist!");
e.printStackTrace();
}
} else if(tme.getColumn() == 0) {
// --- The key value (e.g. the time stamp) was edited ---------------
Number oldKey = (Number) this.getLatestChangedValue();
Number newKey = (Number) this.getValueAt(tme.getFirstRow(), 0);
this.getChartModel().updateKey(oldKey, newKey);
this.getOntologyModel().updateKey(oldKey, newKey);
}
}
}
}
示例9: tableChanged
@Override
public void tableChanged(TableModelEvent tme) {
if(tme.getSource()==this && tme.getFirstRow()>=0){
if(tme.getType()==TableModelEvent.UPDATE){
// --- Update Events in the table ---------------------------------------
try {
int rowIndex = tme.getFirstRow();
int colIndex = tme.getColumn();
Vector<Number> rowVector = this.getRow(rowIndex);
Float xValue = (Float) rowVector.get(1);
Float yValue = (Float) rowVector.get(2);
// --- Do we have changes? ------------------------------------------
if (colIndex==1) {
if (((Float)this.latestChangedValue).equals(xValue)) return;
if (this.getOntologyModel().getSeries(this.getFocusedSeriesIndex()).getAvoidDuplicateXValues()==true) {
// --- Risk of duplicate x values ? -------------------------
if (this.tableModelDataVector.getRowByValue(colIndex, xValue, rowIndex)!=null) {
// --- Another row contains this value, undo ------------
String title = "Doppelte X-Werte nicht zulässig!";
String msg = "Doppelte X-Werte sind derzeit nicht zulässig!\n";
msg += "Die Aktion wird rückgängig gemacht.";
JOptionPane.showMessageDialog(this.myJTable, Language.translate(msg), Language.translate(title), JOptionPane.WARNING_MESSAGE, null);
xValue = (Float) this.latestChangedValue;
this.tableModelDataVector.get(rowIndex).set(colIndex, xValue);
return;
}
}
} else if (colIndex==2) {
if (((Float)this.latestChangedValue).equals(yValue)) return;
}
// --- A value of a series was edited -------------------------------
if(xValue!=null && yValue!=null){
// --- Update new entry in chart and ontology model --------
this.getOntologyModel().updateXyValuePair(this.getFocusedSeriesIndex(), rowIndex, xValue, yValue);
if (this.getOntologyModel().getSeries(this.getFocusedSeriesIndex()).getAutoSort()==true) {
this.tableModelDataVector.sort();
this.getOntologyModel().getSeries(this.getFocusedSeriesIndex()).sort();
// --- Find new position of the row vector -------------
rowIndex = this.tableModelDataVector.indexOf(rowVector);
}
this.getChartModel().setXYSeriesAccordingToOntologyModel(this.getFocusedSeriesIndex());
if (rowIndex!=-1) {
int rowIndexTable = this.myJTable.convertRowIndexToView(rowIndex);
this.myJTable.setRowSelectionInterval(rowIndexTable, rowIndexTable);
this.myJTable.changeSelection(rowIndexTable, 0, false, false);
}
} else {
// --- We have an empty yValue, delete ValuePair ------------
this.tableModelDataVector.remove(rowIndex);
if (this.getRowCount()==0) {
this.parentDataModel.removeSeries(this.getFocusedSeriesIndex());
} else {
this.getOntologyModel().removeXyValuePair(this.getFocusedSeriesIndex(), rowIndex);
this.getChartModel().setXYSeriesAccordingToOntologyModel(this.getFocusedSeriesIndex());
}
}
} catch (NoSuchSeriesException e) {
System.err.println("Error updating data model: Series "+this.getFocusedSeriesIndex()+" does mot exist!");
e.printStackTrace();
}
} else {
// --- Insert or Delete events in the table ---------
}
}
}
示例10: tableChanged
@Override
public void tableChanged(TableModelEvent e) {
if (TableModelEvent.UPDATE == e.getType()) {
this.onTableChage(e);
}
}