本文整理汇总了Java中javax.swing.event.TableModelEvent.getColumn方法的典型用法代码示例。如果您正苦于以下问题:Java TableModelEvent.getColumn方法的具体用法?Java TableModelEvent.getColumn怎么用?Java TableModelEvent.getColumn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.event.TableModelEvent
的用法示例。
在下文中一共展示了TableModelEvent.getColumn方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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();
}
示例3: 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();
}
}
示例4: onTableChage
import javax.swing.event.TableModelEvent; //导入方法依赖的package包/类
private void onTableChage(TableModelEvent e) {
int row = e.getFirstRow();
int column = e.getColumn();
MatchRule rule = scan.getMatchRule(row);
if (rule == null) {
rule = new MatchRule(Pattern.compile("."), 1, "", ScanIssueSeverity.LOW, ScanIssueConfidence.CERTAIN);
scan.addMatchRule(rule);
}
switch (column) {
case 0:
mCallbacks.printOutput("new pattern: " + (String)model.getValueAt(row, column));
rule.setPattern(Pattern.compile((String)model.getValueAt(row, column)));
break;
case 1:
rule.setMatchGroup((Integer)model.getValueAt(row, column));
break;
case 2:
rule.setType((String)model.getValueAt(row, column));
break;
case 3:
rule.setSeverity(ScanIssueSeverity.fromName((String)model.getValueAt(row, column)));
break;
case 4:
rule.setConfidence(ScanIssueConfidence.fromName((String)model.getValueAt(row, column)));
break;
}
}
示例5: 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;
}
示例6: tableChanged
import javax.swing.event.TableModelEvent; //导入方法依赖的package包/类
public void tableChanged(TableModelEvent e) {
// If we're not sorting by anything, just pass the event along.
if (!isSorting()) {
clearSortingState();
fireTableChanged(e);
return;
}
// If the table structure has changed, cancel the sorting; the
// sorting columns may have been either moved or deleted from
// the model.
if (e.getFirstRow() == TableModelEvent.HEADER_ROW) {
cancelSorting();
fireTableChanged(e);
return;
}
// We can map a cell event through to the view without widening
// when the following conditions apply:
//
// a) all the changes are on one row (e.getFirstRow() == e.getLastRow()) and,
// b) all the changes are in one column (column != TableModelEvent.ALL_COLUMNS) and,
// c) we are not sorting on that column (getSortingStatus(column) == NOT_SORTED) and,
// d) a reverse lookup will not trigger a sort (modelToView != null)
//
// Note: INSERT and DELETE events fail this test as they have column == ALL_COLUMNS.
//
// The last check, for (modelToView != null) is to see if modelToView
// is already allocated. If we don't do this check; sorting can become
// a performance bottleneck for applications where cells
// change rapidly in different parts of the table. If cells
// change alternately in the sorting column and then outside of
// it this class can end up re-sorting on alternate cell updates -
// which can be a performance problem for large tables. The last
// clause avoids this problem.
int column = e.getColumn();
if (e.getFirstRow() == e.getLastRow()
&& column != TableModelEvent.ALL_COLUMNS
&& getSortingStatus(column) == NOT_SORTED
&& modelToView != null) {
int viewIndex = getModelToView()[e.getFirstRow()];
fireTableChanged(new TableModelEvent(TableSorter.this,
viewIndex, viewIndex,
column, e.getType()));
return;
}
// Something has happened to the data that may have invalidated the row order.
clearSortingState();
fireTableDataChanged();
}
示例7: tableChanged
import javax.swing.event.TableModelEvent; //导入方法依赖的package包/类
public void tableChanged(TableModelEvent e) {
// If we're not sorting by anything, just pass the event along.
if (!isSorting()) {
clearSortingState();
fireTableChanged(e);
return;
}
// If the table structure has changed, cancel the sorting; the
// sorting columns may have been either moved or deleted from
// the model.
if (e == null || e.getFirstRow() == TableModelEvent.HEADER_ROW) {
cancelSorting();
fireTableChanged(e);
return;
}
// We can map a cell event through to the view without widening
// when the following conditions apply:
//
// a) all the changes are on one row (e.getFirstRow() == e.getLastRow()) and,
// b) all the changes are in one column (column != TableModelEvent.ALL_COLUMNS) and,
// c) we are not sorting on that column (getSortingStatus(column) == NOT_SORTED) and,
// d) a reverse lookup will not trigger a sort (modelToView != null)
//
// Note: INSERT and DELETE events fail this test as they have column == ALL_COLUMNS.
//
// The last check, for (modelToView != null) is to see if modelToView
// is already allocated. If we don't do this check; sorting can become
// a performance bottleneck for applications where cells
// change rapidly in different parts of the table. If cells
// change alternately in the sorting column and then outside of
// it this class can end up re-sorting on alternate cell updates -
// which can be a performance problem for large tables. The last
// clause avoids this problem.
int column = e.getColumn();
if (e.getFirstRow() == e.getLastRow()
&& column != TableModelEvent.ALL_COLUMNS
&& getSortingStatus(column) == NOT_SORTED
&& modelToView != null) {
int viewIndex = getModelToView()[e.getFirstRow()];
fireTableChanged(new TableModelEvent(TableSorter.this,
viewIndex, viewIndex,
column, e.getType()));
return;
}
// Something has happened to the data that may have invalidated the row order.
clearSortingState();
fireTableDataChanged();
return;
}
示例8: tableChanged
import javax.swing.event.TableModelEvent; //导入方法依赖的package包/类
public void tableChanged(TableModelEvent e) {
// If we're not sorting by anything, just pass the event along.
if (!isSorting()) {
clearSortingState();
fireTableChanged(e);
return;
}
// If the table structure has changed, cancel the sorting; the
// sorting columns may have been either moved or deleted from
// the model.
if (e.getFirstRow() == TableModelEvent.HEADER_ROW) {
cancelSorting();
fireTableChanged(e);
return;
}
// We can map a cell event through to the view without widening
// when the event is known to be preserving the sorting or when
// the following conditions apply:
//
// a) all the changes are on one row (e.getFirstRow() == e.getLastRow()) and,
// b) all the changes are in one column (column != TableModelEvent.ALL_COLUMNS) and,
// c) we are not sorting on that column (getSortingStatus(column) == NOT_SORTED) and,
//
// Note: INSERT and DELETE events fail this test as they have column == ALL_COLUMNS.
int column = e.getColumn();
if ((e instanceof SortingSafeTableModelEvent)
|| e.getFirstRow() == e.getLastRow()
&& column != TableModelEvent.ALL_COLUMNS
&& getSortingStatus(column) == NOT_SORTED) {
int viewIndex = getModelToView()[e.getFirstRow()];
fireTableChanged(new TableModelEvent(TableSorter.this,
viewIndex, viewIndex,
column, e.getType()));
return;
}
// Something has happened to the data that may have invalidated the row order.
clearSortingState();
fireTableDataChanged();
}
示例9: tableModelChanged
import javax.swing.event.TableModelEvent; //导入方法依赖的package包/类
private void tableModelChanged(TableModelEvent e) {
Log.getLogger().entering("QueryBuilderGraphFrame", "tableModelChanged");
// We have a mouse click inside a graph table node, indicating select/deselect.
// Propagate the information to the input table
// Extract some information from the event
int row = e.getFirstRow(); // the first row that changed
int column = e.getColumn(); // the column for this event
QueryBuilderTableModel model = (QueryBuilderTableModel) e.getSource();
String tableSpec = model.getTableSpec();
// DB column name
String columnName = (String) model.getValueAt(row, column+2);
// boolean - Selected/deselected
Object value = model.getValueAt(row, column);
if (value==Boolean.TRUE) { // A column has been selected
// Update the query model if appropriate
// Do this first so that it's available when adding the row
if (_queryBuilder._updateModel) {
_queryBuilder.getQueryModel().addColumn(tableSpec, columnName);
_queryBuilderInputTable.selectColumn(tableSpec, columnName, Boolean.TRUE);
}
}
else if (value==Boolean.FALSE) { // A column has been deselected
// Update the query model, if we're not being driven by it
// Do this before updating the grid, because we use the model to generate sortorder
if (_queryBuilder._updateModel) {
_queryBuilder.getQueryModel().removeColumn(tableSpec, columnName); }
// do not remove the whole row, just deselect the output column.
_queryBuilderInputTable.selectColumn(tableSpec, columnName, Boolean.FALSE);
}
// We used to update the text query after every event. That
// caused degraded performance. Now, we check whether we've
// received a real event, or we're generating the graph as a
// batch operation. Also, we trigger only on TableModel events,
// so InputTableMode must explicitly invoke
if (_queryBuilder._updateText) {
// An interactive event -- update the text query
_queryBuilder.generateText();
}
}
示例10: tableChanged
import javax.swing.event.TableModelEvent; //导入方法依赖的package包/类
public void tableChanged(TableModelEvent e) {
// If we're not sorting by anything, just pass the event along.
if (!isSorting()) {
clearSortingState();
fireTableChanged(e);
return;
}
// If the table structure has changed, cancel the sorting; the
// sorting columns may have been either moved or deleted from
// the model.
if (e.getFirstRow() == TableModelEvent.HEADER_ROW) {
cancelSorting();
fireTableChanged(e);
return;
}
// We can map a cell event through to the view without widening
// when the following conditions apply:
//
// a) all the changes are on one row (e.getFirstRow() == e.getLastRow()) and,
// b) all the changes are in one column (column != TableModelEvent.ALL_COLUMNS) and,
// c) we are not sorting on that column (getSortingStatus(column) == NOT_SORTED) and,
// d) a reverse lookup will not trigger a sort (modelToView != null)
//
// Note: INSERT and DELETE events fail this test as they have column == ALL_COLUMNS.
//
// The last check, for (modelToView != null) is to see if modelToView
// is already allocated. If we don't do this check; sorting can become
// a performance bottleneck for applications where cells
// change rapidly in different parts of the table. If cells
// change alternately in the sorting column and then outside of
// it this class can end up re-sorting on alternate cell updates -
// which can be a performance problem for large tables. The last
// clause avoids this problem.
int column = e.getColumn();
if (e.getFirstRow() == e.getLastRow() && column != TableModelEvent.ALL_COLUMNS && getSortingStatus(column) == NOT_SORTED && modelToView != null) {
int viewIndex = getModelToView()[e.getFirstRow()];
fireTableChanged(new TableModelEvent(TableSorter.this,
viewIndex, viewIndex,
column, e.getType()));
return;
}
// Something has happened to the data that may have invalidated the row order.
clearSortingState();
fireTableDataChanged();
return;
}
示例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 ---------------------------------------
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 ---------
}
}
}
示例12: tableChanged
import javax.swing.event.TableModelEvent; //导入方法依赖的package包/类
public void tableChanged(TableModelEvent e) {
// If we're not sorting by anything, just pass the event along.
if (!isSorting()) {
clearSortingState();
fireTableChanged(e);
return;
}
// If the table structure has changed, cancel the sorting; the
// sorting columns may have been either moved or deleted from
// the model.
if (e.getFirstRow() == TableModelEvent.HEADER_ROW) {
cancelSorting();
fireTableChanged(e);
return;
}
// We can map a cell event through to the view without widening
// when the following conditions apply:
//
// a) all the changes are on one row (e.getFirstRow() ==
// e.getLastRow()) and,
// b) all the changes are in one column (column !=
// TableModelEvent.ALL_COLUMNS) and,
// c) we are not sorting on that column (getSortingStatus(column) ==
// NOT_SORTED) and,
// d) a reverse lookup will not trigger a sort (modelToView != null)
//
// Note: INSERT and DELETE events fail this test as they have column
// == ALL_COLUMNS.
//
// The last check, for (modelToView != null) is to see if
// modelToView
// is already allocated. If we don't do this check; sorting can
// become
// a performance bottleneck for applications where cells
// change rapidly in different parts of the table. If cells
// change alternately in the sorting column and then outside of
// it this class can end up re-sorting on alternate cell updates -
// which can be a performance problem for large tables. The last
// clause avoids this problem.
int column = e.getColumn();
if (e.getFirstRow() == e.getLastRow() && column != TableModelEvent.ALL_COLUMNS && getSortingStatus(column) == NOT_SORTED
&& modelToView != null) {
int viewIndex = getModelToView()[e.getFirstRow()];
fireTableChanged(new TableModelEvent(TableSorter.this, viewIndex, viewIndex, column, e.getType()));
return;
}
// Something has happened to the data that may have invalidated the
// row order.
clearSortingState();
fireTableDataChanged();
return;
}
示例13: tableChanged
import javax.swing.event.TableModelEvent; //导入方法依赖的package包/类
@Override
public void tableChanged(TableModelEvent e)
{
// If we're not sorting by anything, just pass the event along.
if( !isSorting() )
{
clearSortingState();
fireTableChanged(e);
return;
}
// If the table structure has changed, cancel the sorting; the
// sorting columns may have been either moved or deleted from
// the model.
if( e.getFirstRow() == TableModelEvent.HEADER_ROW )
{
cancelSorting();
fireTableChanged(e);
return;
}
// We can map a cell event through to the view without widening
// when the following conditions apply:
//
// a) all the changes are on one row (e.getFirstRow() ==
// e.getLastRow()) and,
// b) all the changes are in one column (column !=
// TableModelEvent.ALL_COLUMNS) and,
// c) we are not sorting on that column (getSortingStatus(column) ==
// NOT_SORTED) and,
// d) a reverse lookup will not trigger a sort (modelToView != null)
//
// Note: INSERT and DELETE events fail this test as they have column
// == ALL_COLUMNS.
//
// The last check, for (modelToView != null) is to see if
// modelToView
// is already allocated. If we don't do this check; sorting can
// become
// a performance bottleneck for applications where cells
// change rapidly in different parts of the table. If cells
// change alternately in the sorting column and then outside of
// it this class can end up re-sorting on alternate cell updates -
// which can be a performance problem for large tables. The last
// clause avoids this problem.
int column = e.getColumn();
if( e.getFirstRow() == e.getLastRow() && column != TableModelEvent.ALL_COLUMNS
&& getSortingStatus(column) == NOT_SORTED && modelToView != null )
{
int viewIndex = getModelToView()[e.getFirstRow()];
fireTableChanged(new TableModelEvent(TableSorter.this, viewIndex, viewIndex, column, e.getType()));
return;
}
// Something has happened to the data that may have invalidated the
// row order.
clearSortingState();
fireTableDataChanged();
return;
}