本文整理汇总了Java中javax.swing.event.TableModelEvent.getType方法的典型用法代码示例。如果您正苦于以下问题:Java TableModelEvent.getType方法的具体用法?Java TableModelEvent.getType怎么用?Java TableModelEvent.getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.event.TableModelEvent
的用法示例。
在下文中一共展示了TableModelEvent.getType方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: tableChanged
import javax.swing.event.TableModelEvent; //导入方法依赖的package包/类
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
import javax.swing.event.TableModelEvent; //导入方法依赖的package包/类
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: tableChanged
import javax.swing.event.TableModelEvent; //导入方法依赖的package包/类
/**
* TableModel listener
*
* @param e
*/
@Override
public void tableChanged(TableModelEvent e) {
// TODO Do something with the data...
System.out.println(e.getType());
if (e.getType() == TableModelEvent.INSERT) {
//TODO update all files
// TranslationTableModel model = (TranslationTableModel) editor.getTable1().getModel();
String lang = editor.getCurrentLang();
VirtualFile file = getFileMap().get(lang);
if (file.exists()) {
YAMLFileImpl yamlFile = (YAMLFileImpl) PsiManager.getInstance(project).findFile(file);
if (yamlFile != null) {
System.out.println(yamlFile);
}
}
}
}
示例4: tableModelEventToString
import javax.swing.event.TableModelEvent; //导入方法依赖的package包/类
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();
}
示例5: tableChanged
import javax.swing.event.TableModelEvent; //导入方法依赖的package包/类
/**
* 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);
}
}
示例6: tableChanged
import javax.swing.event.TableModelEvent; //导入方法依赖的package包/类
@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();
}
}
示例7: tableChanged
import javax.swing.event.TableModelEvent; //导入方法依赖的package包/类
@Override
public void tableChanged(TableModelEvent e)
{
super.tableChanged(e);
if (e.getType() == TableModelEvent.INSERT)
scrollToBottom();
else if (e.getType() == 42)
{
finishcolor = (finishcolor+1)%2;
totalRenderer.setHighlight(finishcolor);
seqRenderer.setHighlight(finishcolor);
getSelectionModel().setSelectionInterval(e.getFirstRow(), e.getLastRow());
Toolkit.getDefaultToolkit().beep();
}
}
示例8: translateEvent
import javax.swing.event.TableModelEvent; //导入方法依赖的package包/类
/** Creates a TableModelEvent identical to the original except that the
* column index has been shifted by +1. This is used to refire events
* from the ProxyTableModel (generated by RowModel.setValueFor()) as
* change events on the OutlineModel. */
private TableModelEvent translateEvent (TableModelEvent e) {
TableModelEvent nue = new TableModelEvent (getModel(),
e.getFirstRow(), e.getLastRow(), e.getColumn()+1, e.getType());
return nue;
}
示例9: tableChanged
import javax.swing.event.TableModelEvent; //导入方法依赖的package包/类
public void tableChanged(TableModelEvent evt) {
if (evt.getType() == TableModelEvent.UPDATE) {
validateTable(evt.getFirstRow(), evt.getColumn());
}
}
示例10: tableChanged
import javax.swing.event.TableModelEvent; //导入方法依赖的package包/类
public void tableChanged(TableModelEvent e) {
super.tableChanged(e);
if (e.getType() == TableModelEvent.INSERT) updateColumns(false);
}
示例11: tableChanged
import javax.swing.event.TableModelEvent; //导入方法依赖的package包/类
@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);
}
}
}
}
示例12: tableChanged
import javax.swing.event.TableModelEvent; //导入方法依赖的package包/类
@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 ---------
}
}
}
示例13: initToolBar
import javax.swing.event.TableModelEvent; //导入方法依赖的package包/类
/**
* Initialize context menu and toolbar.
*/
private void initToolBar() {
toolbar = new JToolBar();
toolbar.add(new Button(firstPageAction));
toolbar.add(new Button(pageUpAction));
toolbar.add(new Button(pageDownAction));
toolbar.add(new Button(lastPageAction));
toolbar.addSeparator();
toolbar.add(pageSizeLabel);
toolbar.add(pageSizeField);
pageSizeField.setText(Integer.toString(getPageSize()));
pageSizeField.setHorizontalAlignment(JTextField.RIGHT);
pageSizeField.setAction(pageSizeAction);
pageSizeField.setMaximumSize(pageSizeField.getPreferredSize());
toolbar.addSeparator();
totalRowCountLabel.setText(String.format(totalRowCountLabelFormat, getRealRowCount()));
toolbar.add(totalRowCountLabel);
toolbar.add(pageField);
pageField.setText(Integer.toString(getPage() + 1));
pageField.setHorizontalAlignment(JTextField.RIGHT);
pageField.setAction(gotoPageAction);
pageField.setMaximumSize(pageField.getPreferredSize());
pageCountLabel.setText(String.format(pageCountLabelFormat, getPageCount()));
toolbar.add(pageCountLabel);
setActionEnabled();
TableModelListener listener = new TableModelListener() {
@Override
public void tableChanged(TableModelEvent tme) {
if (tme.getType() == TableModelEvent.INSERT || tme.getType() == TableModelEvent.DELETE) {
if (getPage() >= getPageCount()) {
setPage(getPageCount() - 1);
}
totalRowCountLabel.setText(String.format(totalRowCountLabelFormat, getRealRowCount()));
pageField.setText(Integer.toString(getPage() + 1));
pageCountLabel.setText(String.format(pageCountLabelFormat, getPageCount()));
}
}
};
addTableModelListener(listener);
}
示例14: tableChanged
import javax.swing.event.TableModelEvent; //导入方法依赖的package包/类
@Override
public void tableChanged(TableModelEvent e) {
if (TableModelEvent.UPDATE == e.getType()) {
this.onTableChage(e);
}
}