本文整理匯總了Java中javax.swing.event.TableModelListener類的典型用法代碼示例。如果您正苦於以下問題:Java TableModelListener類的具體用法?Java TableModelListener怎麽用?Java TableModelListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
TableModelListener類屬於javax.swing.event包,在下文中一共展示了TableModelListener類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createBarChart
import javax.swing.event.TableModelListener; //導入依賴的package包/類
private BarChart createBarChart() {
CategoryAxis xAxis = new CategoryAxis();
xAxis.setCategories(FXCollections.<String>observableArrayList(tableModel.getColumnNames()));
xAxis.setLabel("Year");
double tickUnit = tableModel.getTickUnit();
NumberAxis yAxis = new NumberAxis();
yAxis.setTickUnit(tickUnit);
yAxis.setLabel("Units Sold");
final BarChart chart = new BarChart(xAxis, yAxis, tableModel.getBarChartData());
tableModel.addTableModelListener(new TableModelListener() {
public void tableChanged(TableModelEvent e) {
if (e.getType() == TableModelEvent.UPDATE) {
final int row = e.getFirstRow();
final int column = e.getColumn();
final Object value = ((SampleTableModel) e.getSource()).getValueAt(row, column);
Platform.runLater(new Runnable() {
public void run() {
XYChart.Series<String, Number> s = (XYChart.Series<String, Number>) chart.getData().get(row);
BarChart.Data data = s.getData().get(column);
data.setYValue(value);
}
});
}
}
});
return chart;
}
示例2: fireTableChange
import javax.swing.event.TableModelListener; //導入依賴的package包/類
/** Fires multiple table model events, setting the inMultiEvent flag
* as appropriate. */
private void fireTableChange (TableModelEvent[] e) {
//Event may be null for offscreen info, etc.
if (e == null || e.length==0) {
return;
}
TableModelListener[] listeners = getTableModelListeners();
inMultiEvent = e.length > 1;
//System.err.println("fireTableChange("+Arrays.toString(e)+")");
try {
for (int i=0; i < e.length; i++) {
if (i == e.length-1) {
inMultiEvent = false;
}
fireTableChange (e[i], listeners);
}
} finally {
inMultiEvent = false;
}
}
示例3: propertyChange
import javax.swing.event.TableModelListener; //導入依賴的package包/類
@Override
public void propertyChange(PropertyChangeEvent evt) {
// Keep the row table in sync with the main table
if ("rowHeight".equals(evt.getPropertyName())) {
repaint();
}
if ("model".equals(evt.getPropertyName())) {
contentTable.getModel().addTableModelListener(new TableModelListener() {
@Override
public void tableChanged(TableModelEvent e) {
revalidate();
}
});
revalidate();
}
}
示例4: setupTableModelListener
import javax.swing.event.TableModelListener; //導入依賴的package包/類
private void setupTableModelListener() {
//add listener which responds to tableChanged that is fired
//by variationPerParameterTableModel.setValueAt().
this.variationPerParameterTableModel.addTableModelListener(new TableModelListener() {
public void tableChanged(TableModelEvent e) {
//update currentVariationFunctionContext.
Variation variationFunction = variationPerParameterTableModel.getUncertaintiesObject()
.getVariationFunction(variationPerParameterTableModel.getCurrentRow());
setCurrentVariationFunctionContext(new VariationFunctionContext(variationFunction));
//update panel.
updateVariationPerParameterSidePanel();
//select row of currentVariationFunctionContext.
int selectedRowIndex = variationPerParameterTableModel.getCurrentRow();
setSelectedRow(selectedRowIndex);
}
});
}
示例5: updateCorrelationModelParametersTable
import javax.swing.event.TableModelListener; //導入依賴的package包/類
/**
* Update the Correlation model Parameters Table.
*/
private void updateCorrelationModelParametersTable() {
// Populate the correlation model parameters table.
FunctionParameterTableModel parameterTableModel = new FunctionParameterTableModel(this.currentAutoCorrelationFunctionContext);
this.parentController.getMainPanel().getAutoCorrelationParameterAndGraphPanel().getParametersTable()
.setModel(parameterTableModel);
//setup cell editor.
TableColumn columnValue = parentController.getMainPanel().getAutoCorrelationParameterAndGraphPanel()
.getParametersTable().getColumnModel().getColumn(FunctionParameterTableModel.COLUMN_VALUE);
columnValue.setCellEditor(new TextCellEditor());
parameterTableModel.addTableModelListener(new TableModelListener() {
public void tableChanged(TableModelEvent e) {
updateCorrelationModelGraph();
}
});
}
示例6: updatePDFDefinitionParametersTable
import javax.swing.event.TableModelListener; //導入依賴的package包/類
/**
* Update the PDFDefinition Parameters Table.
*/
private void updatePDFDefinitionParametersTable() {
// Populate the correlation model parameters table.
FunctionParameterTableModel parameterTableModel;
if (this.currentPdfContext != null && this.currentPdfContext.getPdfObject() != null) {
parameterTableModel = new FunctionParameterTableModel(this.currentPdfContext);
parentController.getMainPanel().getPdfParameterAndGraphPanel().getParametersTable()
.setModel(parameterTableModel);
//setup cell editor.
TableColumn columnValue = parentController.getMainPanel().getPdfParameterAndGraphPanel()
.getParametersTable().getColumnModel().getColumn(FunctionParameterTableModel.COLUMN_VALUE);
columnValue.setCellEditor(new TextCellEditor());
parameterTableModel.addTableModelListener(new TableModelListener() {
public void tableChanged(TableModelEvent e) {
updatePDFDefinitionGraph();
}
});
}
}
示例7: getPropertiesPanel
import javax.swing.event.TableModelListener; //導入依賴的package包/類
private PropertiesTable getPropertiesPanel() {
PropertiesTable result = this.propertiesPanel;
if (result == null) {
this.propertiesPanel = result = new PropertiesTable(GraphProperties.Key.class, true);
result.setName("Properties");
result.setBackground(JAttr.EDITOR_BACKGROUND);
result.setProperties(GraphInfo.getProperties(getGraph()));
// add the listener after initialising the properties, to avoid needless refreshes
result.getModel()
.addTableModelListener(new TableModelListener() {
@Override
public void tableChanged(TableModelEvent e) {
if (GraphEditorTab.this.listenToPropertiesPanel) {
changeProperties(GraphEditorTab.this.propertiesPanel.getProperties(),
false);
setDirty(false);
}
}
});
this.listenToPropertiesPanel = true;
}
return result;
}
示例8: deletecol
import javax.swing.event.TableModelListener; //導入依賴的package包/類
/**
* Delete a single column from the table model
*
* @param table target table
* @param col target column
* @deprecated
*/
static void deletecol(JTable table, int col) {
DefaultTableModel tmodel = (DefaultTableModel) table.getModel();
DefaultTableModel tmodel1 = new DefaultTableModel();
TableModelListener[] listeners = tmodel.getTableModelListeners();
Vector<?> v = tmodel.getDataVector();
Vector<?> v1 = newvector(v, col);
tmodel1.setDataVector(v1, getColumnIdentifiersremovecol(table, col));
table.setModel(tmodel1);
for (TableModelListener l : listeners) {
tmodel1.addTableModelListener(l);
}
}
示例9: addcol
import javax.swing.event.TableModelListener; //導入依賴的package包/類
/**
* Adding column is done by creating new model by modifying older one.<p>
*
* Insert new column if column is outside the <code>limit</code> Adds new
* column if selected column inside the <code>limit</code>[email protected] _table
* target table
*
* @param limit the range to avoid inserting
*/
static void addcol(JTable table, int limit) {
try {
int sc = table.getSelectedColumn();
if (sc < limit - 1) {
sc = table.getColumnCount() - 1;
}
DefaultTableModel tableM = (DefaultTableModel) table.getModel();
DefaultTableModel tableM1 = new DefaultTableModel();
TableModelListener[] listeners = tableM.getTableModelListeners();
tableM1.setDataVector(newvectoraddcol(tableM.getDataVector(), sc), getColumnIdentifiersaddcol(sc + 1, table));
table.setModel(tableM1);
for (TableModelListener l : listeners) {
tableM1.addTableModelListener(l);
}
} catch (Exception ex) {
Logger.getLogger(JtableUtils.class.getName()).log(Level.SEVERE, null, ex);
}
}
示例10: test218096
import javax.swing.event.TableModelListener; //導入依賴的package包/類
public void test218096() {
String[][] nodesDesc = new String[][]{
new String[]{"a", "b", "c"},
new String[]{"D", "E", "F"},
new String[]{"g", "h", "i"}};
Node rootNode = new TestNode(new StringListKeys(nodesDesc), "root");
OutlineViewComponent comp = new OutlineViewComponent(rootNode);
Node[] rootChildNodes = rootNode.getChildren().getNodes();
assertEquals(3, rootChildNodes.length);
Node[] firstNodeChildren = rootChildNodes[0].getChildren().getNodes();
assertEquals(3, firstNodeChildren.length);
comp.view.expandNode(rootChildNodes[0]);
assertEquals(6, comp.view.getOutline().getRowCount());
VisualizerNode dParentVisNode = (VisualizerNode) comp.view.getOutline()
.getModel().getValueAt(4, 0);
assertEquals("Dparent", dParentVisNode.getDisplayName());
TestNode.MarkedCookie mc = rootChildNodes[1].getLookup().lookup(
TestNode.MarkedCookie.class);
final AtomicBoolean notifiedAboutChange = new AtomicBoolean(false);
comp.view.getOutline().getModel().addTableModelListener(
new TableModelListener() {
@Override
public void tableChanged(TableModelEvent e) {
if (e.getFirstRow() <= 4 && e.getLastRow() >= 4) {
notifiedAboutChange.set(true);
}
}
});
mc.setMarked(true);
assertTrue("Table model should be notified about name change",
notifiedAboutChange.get());
}
示例11: RunPortBindingsVisual
import javax.swing.event.TableModelListener; //導入依賴的package包/類
/**
* Creates new form RunNetworkVisual
*/
public RunPortBindingsVisual(DockerImageDetail info) {
initComponents();
this.info = info;
addExposedButton.setEnabled(info != null && !info.getExposedPorts().isEmpty());
portMappingTable.setModel(model);
UiUtils.configureRowHeight(portMappingTable);
TableColumn typeColumn = portMappingTable.getColumnModel().getColumn(0);
JComboBox typeCombo = new JComboBox(ExposedPort.Type.values());
typeColumn.setCellEditor(new DefaultCellEditor(typeCombo));
typeColumn.setPreferredWidth(typeColumn.getPreferredWidth() / 2);
TableColumn portColumn = portMappingTable.getColumnModel().getColumn(2);
portColumn.setCellRenderer(new CellRenderer("<random>", false));
TableColumn addressColumn = portMappingTable.getColumnModel().getColumn(3);
JComboBox addressCombo = new JComboBox(UiUtils.getAddresses(false, false).toArray());
addressCombo.setEditable(true);
addressColumn.setCellEditor(new DefaultCellEditor(addressCombo));
addressColumn.setCellRenderer(new CellRenderer("<any>", false));
addressColumn.setPreferredWidth(addressColumn.getPreferredWidth() * 2);
portMappingTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
model.addTableModelListener(new TableModelListener() {
@Override
public void tableChanged(TableModelEvent e) {
changeSupport.fireChange();
}
});
}
示例12: getTableModelListeners
import javax.swing.event.TableModelListener; //導入依賴的package包/類
/** Fetch an array of the currently registered table model listeners */
private TableModelListener[] getTableModelListeners() {
TableModelListener[] listeners;
synchronized (this) {
listeners = new TableModelListener[
tableListeners.size()];
listeners = tableListeners.toArray(listeners);
}
return listeners;
}
示例13: fire
import javax.swing.event.TableModelListener; //導入依賴的package包/類
private void fire (TableModelEvent e) {
TableModelListener[] l;
synchronized (this) {
l = new TableModelListener[listeners.size()];
l = listeners.toArray (l);
}
for (int i=0; i < l.length; i++) {
l[i].tableChanged(e);
}
}
示例14: TabTable
import javax.swing.event.TableModelListener; //導入依賴的package包/類
protected TabTable( TabTableModel tableModel, int orientation ) {
super( tableModel );
this.orientation = orientation;
getModel().addTableModelListener( new TableModelListener() {
@Override
public void tableChanged( TableModelEvent e ) {
if( e.getFirstRow() != TableModelEvent.HEADER_ROW )
adjustColumnWidths();
}
});
configure();
}
示例15: separateStaticImportsCheckBoxActionPerformed
import javax.swing.event.TableModelListener; //導入依賴的package包/類
private void separateStaticImportsCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_separateStaticImportsCheckBoxActionPerformed
TableModel oldModel = importLayoutTable.getModel();
TableModel newModel = (DefaultTableModel)createTableModel(importGroupsOrder, preferences);
importLayoutTable.setModel(newModel);
setImportLayoutTableColumnsWidth();
for (TableModelListener l : ((DefaultTableModel)oldModel).getTableModelListeners()) {
oldModel.removeTableModelListener(l);
newModel.addTableModelListener(l);
l.tableChanged(null);
}
}