当前位置: 首页>>代码示例>>Java>>正文


Java TableModelListener类代码示例

本文整理汇总了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;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:33,代码来源:SwingInterop.java

示例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;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:EventBroadcaster.java

示例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();
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:19,代码来源:RowNumberTable.java

示例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);
      	}
      });
  }
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:20,代码来源:VariationPerParameterTableController.java

示例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();
		}
	});
}
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:22,代码来源:CorrelationTableController.java

示例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();
			}
		});
       }
}
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:25,代码来源:PDFDefinitionTableController.java

示例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;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:24,代码来源:GraphEditorTab.java

示例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);
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:21,代码来源:JtableUtils.java

示例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);
    }

}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:32,代码来源:JtableUtils.java

示例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());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:OutlineView218096Test.java

示例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();
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:RunPortBindingsVisual.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:EventBroadcaster.java

示例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);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:ProxyTableModel.java

示例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();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:TabTable.java

示例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);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:FmtImports.java


注:本文中的javax.swing.event.TableModelListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。