本文整理匯總了Java中javax.swing.event.TableModelEvent.getFirstRow方法的典型用法代碼示例。如果您正苦於以下問題:Java TableModelEvent.getFirstRow方法的具體用法?Java TableModelEvent.getFirstRow怎麽用?Java TableModelEvent.getFirstRow使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.event.TableModelEvent
的用法示例。
在下文中一共展示了TableModelEvent.getFirstRow方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: tableChanged
import javax.swing.event.TableModelEvent; //導入方法依賴的package包/類
/***
* Intercept changes to model so we can re-add our columns
* @param e the table event
*/
@Override
public void tableChanged(TableModelEvent e)
{
if (e == null || e.getFirstRow() == TableModelEvent.HEADER_ROW)
{
TableColumnModel tcm = getColumnModel();
TableModel m = getModel();
if (m != null)
{
// Remove any current columns
while (tcm.getColumnCount() > 0) {
tcm.removeColumn(tcm.getColumn(0));
}
// Create new columns from the data model info
for (int ii = startModelColumn; ii < m.getColumnCount() && ii < endModelColumn; ii++) {
TableColumn newColumn = new TableColumn(ii);
addColumn(newColumn);
}
}
}
super.tableChanged(e);
}
示例2: tableChanged
import javax.swing.event.TableModelEvent; //導入方法依賴的package包/類
public void tableChanged(TableModelEvent e) {
//System.out.println("TBALE changed");
//boolean prefixFlag = false;
int row = e.getFirstRow();
int column = e.getColumn();
AbstractTableModel tblModel = (AbstractTableModel) e.getSource();
Object data = tblModel.getValueAt(row, column);
if(column == SCHEMA_COL) {
SchemaObject rowValue = (SchemaObject)data;
if(rowValue.toString().equals(startString))
return;
String genPrefix = (String) tblModel.getValueAt(row, PREFIX_COL);
if (genPrefix == null || genPrefix.equals(" ") ) {
String prefix = generateUniquePrefix();
tableModel.setValueAt(prefix, row, PREFIX_COL);
}
if(row == tableModel.getRowCount() - 1) {
addRow(startString);
}
//if its the first row, then select it as primary
if(row == 0) {
// System.out.println("added first row");
tblModel.setValueAt(new Boolean(true), 0, 0);
}
}
}
示例3: tableChanged
import javax.swing.event.TableModelEvent; //導入方法依賴的package包/類
@Override
public void tableChanged(TableModelEvent tme) {
int seriesIndex = tme.getFirstRow();
try{
if(tme.getColumn() == 0){
this.setSeriesLabel(seriesIndex, (String) this.chartSettingModel.getTableModelSeriesSettings().getValueAt(seriesIndex, 0));
}else if(tme.getColumn() == 1){
this.setSeriesColor(seriesIndex, (Color) this.chartSettingModel.getTableModelSeriesSettings().getValueAt(seriesIndex, 1));
}else if(tme.getColumn() == 2){
this.setSeriesLineWidth(seriesIndex, (Float) this.chartSettingModel.getTableModelSeriesSettings().getValueAt(seriesIndex, 2));
}
} catch (NoSuchSeriesException ex) {
System.err.println("Error changing settings for series "+seriesIndex);
ex.printStackTrace();
}
}
示例4: 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();
}
}
示例5: 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();
}
示例6: tableChanged
import javax.swing.event.TableModelEvent; //導入方法依賴的package包/類
/**
* Overridden to make sure column sizes are mantained
*/
@Override
public void tableChanged(TableModelEvent e) {
super.tableChanged(e);
if ((e == null || e.getFirstRow() == TableModelEvent.HEADER_ROW)) {
sizeColumns();
}
}
示例7: TablePanel
import javax.swing.event.TableModelEvent; //導入方法依賴的package包/類
/**
* Creates a new {@link TablePanel} instance.
*
* @param model
* @param useScrollPane
* if set to <code>true</code>, will add a scrollpane around the GUI.
* @param hideUnavailableContentAssist
* if <code>true</code>, the content assist button will be hidden if no content
* assist is available for the given field
*/
public TablePanel(final TablePanelModel model, boolean useScrollPane, boolean hideUnavailableContentAssist) {
this.mapOfComponents = new HashMap<>();
this.useScrollPane = useScrollPane;
this.hideUnavailableContentAssist = hideUnavailableContentAssist;
this.listener = new TableModelListener() {
@Override
public void tableChanged(TableModelEvent e) {
// table structure changed, re-create it
if (e.getFirstRow() == TableModelEvent.HEADER_ROW) {
createGUI();
} else {
updateComponent(e.getFirstRow(), e.getColumn());
}
}
};
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
initGUI();
setModel(model);
}
});
}
示例8: tableChanged
import javax.swing.event.TableModelEvent; //導入方法依賴的package包/類
public void tableChanged(TableModelEvent e) {
int row=e.getFirstRow();
int userId=Integer.parseInt(table.getValueAt(row, 0).toString());
String userName=table.getValueAt(row, 1).toString();
String pwdString=table.getValueAt(row, 2).toString();
//String IP=table.getValueAt(row, 3).toString();
//String state=table.getValueAt(row, 4).toString();
String userGender=table.getValueAt(row, 5).toString();
String userEmail=table.getValueAt(row, 6).toString();
//String userSignature=table.getValueAt(row, 5).toString();
Date userBirthday=Date.valueOf(table.getValueAt(row, 9).toString());
Users user=new Users(userId,userName,pwdString, userGender, userEmail,userBirthday);
UserDao userDao=new UserDao();
try {
if(userDao.update(user))
{
JOptionPane.showMessageDialog(null, "修改成功!");
}
else {
JOptionPane.showMessageDialog(null, "修改失敗!");
}
} catch (HeadlessException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
示例9: 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;
}
示例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 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();
}
示例11: 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;
}
示例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(e.getFirstRow() == TableModelEvent.HEADER_ROW) {
updateHeader();
}
}
示例14: tableChanged
import javax.swing.event.TableModelEvent; //導入方法依賴的package包/類
@Override
public void tableChanged(TableModelEvent tme) {
if (this.quiteTabelModelListener==true) return;
int row = tme.getFirstRow();
int column = tme.getColumn();
DefaultTableModel model = (DefaultTableModel) tme.getSource();
if (column == 0 && row >= 0 && row < model.getRowCount()) {
String oldCompID = this.currNetworkComponent.getId();
String newCompID = (String) model.getValueAt(row, column);
if (!oldCompID.equals(newCompID)) {
String message = null;
String title = "Warning";
if (newCompID == null || newCompID.length() == 0) {
// --- Check if the component id is empty
message = "Enter a valid name";
JOptionPane.showMessageDialog(this, Language.translate(message, Language.EN), Language.translate(title, Language.EN), JOptionPane.WARNING_MESSAGE);
getJTableComponents().getModel().setValueAt(oldCompID, row, column);
} else if (newCompID.contains(" ")) {
// --- Check for spaces
message = "Enter the name without spaces";
JOptionPane.showMessageDialog(this, Language.translate(message, Language.EN), Language.translate(title, Language.EN), JOptionPane.WARNING_MESSAGE);
getJTableComponents().getModel().setValueAt(oldCompID, row, column);
} else if (getGraphController().getNetworkModelAdapter().getNetworkComponent(newCompID) != null) {
// --- Check if a network component name already exists
message = "The component name already exists!" + newLine + "Choose a different one.";
JOptionPane.showMessageDialog(this, Language.translate(message, Language.EN), Language.translate(title, Language.EN), JOptionPane.WARNING_MESSAGE);
getJTableComponents().getModel().setValueAt(oldCompID, row, column);
} else if (this.getGraphController().getProject().getSimulationSetups().getCurrSimSetup().isAgentNameExists(newCompID)) {
// --- Check if the agent name already exists in the simulation setup
message = "An agent with the name already exists in the simulation setup!" + newLine + " Choose a different one.";
JOptionPane.showMessageDialog(this, Language.translate(message, Language.EN), Language.translate(title, Language.EN), JOptionPane.WARNING_MESSAGE);
getJTableComponents().getModel().setValueAt(oldCompID, row, column);
} else {
// --- All validations done, rename the component and update the network model
// --- renaming NetworkComponents and GraphElements
this.getGraphController().getNetworkModelAdapter().renameNetworkComponent(oldCompID, newCompID);
}
}
}
// System.out.println(row+","+column);
}
示例15: 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);
}
}
}
}