本文整理汇总了Java中javax.swing.table.TableModel.addTableModelListener方法的典型用法代码示例。如果您正苦于以下问题:Java TableModel.addTableModelListener方法的具体用法?Java TableModel.addTableModelListener怎么用?Java TableModel.addTableModelListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.table.TableModel
的用法示例。
在下文中一共展示了TableModel.addTableModelListener方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DefaultOutlineModel
import javax.swing.table.TableModel; //导入方法依赖的package包/类
/** Creates a new instance of DefaultOutlineModel. <strong><b>Note</b>
* Do not fire table structure changes from the wrapped TableModel (value
* changes are okay). Changes that affect the number of rows must come
* from the TreeModel.
* @param treeModel The tree model
* @param tableModel The table model
* @param largeModel <code>true</code> if it's a large model tree, <code>false</code> otherwise.
* @param nodesColumnLabel Label of the node's column
*/
protected DefaultOutlineModel(TreeModel treeModel, TableModel tableModel, boolean largeModel, String nodesColumnLabel) {
this.treeModel = treeModel;
this.tableModel = tableModel;
if (nodesColumnLabel != null) {
this.nodesColumnLabel = nodesColumnLabel;
}
layout = largeModel ? (AbstractLayoutCache) new FixedHeightLayoutCache()
: (AbstractLayoutCache) new VariableHeightLayoutCache();
broadcaster = new EventBroadcaster (this);
layout.setRootVisible(true);
layout.setModel(this);
treePathSupport = new TreePathSupport(this, layout);
treePathSupport.addTreeExpansionListener(broadcaster);
treePathSupport.addTreeWillExpandListener(broadcaster);
treeModel.addTreeModelListener(broadcaster);
tableModel.addTableModelListener(broadcaster);
if (tableModel instanceof ProxyTableModel) {
((ProxyTableModel) tableModel).setOutlineModel(this);
}
}
示例2: setModel
import javax.swing.table.TableModel; //导入方法依赖的package包/类
@Override
@SuppressWarnings({"unchecked"})
public void setModel(TableModel dataModel) {
if (!(dataModel instanceof DataViewTableUIModel)) {
throw new IllegalArgumentException("DataViewTableUI only supports"
+ " instances of DataViewTableUIModel");
}
if (getModel() != null) {
getModel().removeTableModelListener(dataChangedListener); // Remove ChangeListener on replace
}
super.setModel(dataModel);
dataModel.addTableModelListener(dataChangedListener); // Add new change listener
if (dataviewUI != null) {
dataviewUI.handleColumnUpdated();
}
}
示例3: getTableCellEditorComponent
import javax.swing.table.TableModel; //导入方法依赖的package包/类
@Override
public Component getTableCellEditorComponent(JTable table,
Object value,
boolean isSelected,
int r, int c) {
TableModel tableModel = outline.getModel();
tableModel.addTableModelListener(this);
return super.getTableCellEditorComponent(table, value, isSelected, r, c);
}
示例4: PropertyEditorPanel
import javax.swing.table.TableModel; //导入方法依赖的package包/类
public PropertyEditorPanel(Properties initalValue, boolean editable) {
initComponents();
this.value = initalValue;
this.editable = editable;
propertyTable.putClientProperty(
"terminateEditOnFocusLost", Boolean.TRUE); //NOI18N
updateTableFromEditor();
final TableModel tm = propertyTable.getModel();
tm.addTableModelListener(new TableModelListener() {
@Override
public void tableChanged(TableModelEvent tme) {
synchronized (PropertyEditorPanel.this) {
if (updateing) {
return;
}
updateing = true;
Properties p = new Properties();
for (int i = 0; i < tm.getRowCount(); i++) {
p.setProperty((String) tm.getValueAt(i, 0), (String) tm.getValueAt(i, 1));
}
Properties oldValue = value;
value = p;
firePropertyChange(PROP_VALUE, oldValue, value);
updateing = false;
}
}
});
propertyTable.getSelectionModel().addListSelectionListener(
new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent lse) {
updateRemoveButtonSensible();
}
});
updateAddButtonSensible();
updateRemoveButtonSensible();
}
示例5: separateStaticImportsCheckBoxActionPerformed
import javax.swing.table.TableModel; //导入方法依赖的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);
}
}
示例6: setModel
import javax.swing.table.TableModel; //导入方法依赖的package包/类
@Override
public void setModel(final TableModel model) {
boolean shouldSort = this.sortable && checkIfSortable(model);
if (shouldSort) {
this.tableSorter = new ExtendedJTableSorterModel(model);
this.tableSorter.setTableHeader(getTableHeader());
super.setModel(this.tableSorter);
} else {
super.setModel(model);
this.tableSorter = null;
}
originalOrder = new String[model.getColumnCount()];
for (int c = 0; c < model.getColumnCount(); c++) {
originalOrder[c] = model.getColumnName(c);
}
// initializing arrays for cell renderer settings
cutOnLineBreaks = new boolean[model.getColumnCount()];
maximalTextLengths = new int[model.getColumnCount()];
Arrays.fill(maximalTextLengths, Integer.MAX_VALUE);
model.addTableModelListener(new TableModelListener() {
@Override
public void tableChanged(final TableModelEvent e) {
int oldLength = cutOnLineBreaks.length;
if (oldLength != model.getColumnCount()) {
cutOnLineBreaks = Arrays.copyOf(cutOnLineBreaks, model.getColumnCount());
maximalTextLengths = Arrays.copyOf(maximalTextLengths, model.getColumnCount());
if (oldLength < cutOnLineBreaks.length) {
Arrays.fill(cutOnLineBreaks, oldLength, cutOnLineBreaks.length, false);
Arrays.fill(maximalTextLengths, oldLength, cutOnLineBreaks.length, Integer.MAX_VALUE);
}
}
}
});
}
示例7: fillPropertiesTable
import javax.swing.table.TableModel; //导入方法依赖的package包/类
private void fillPropertiesTable(final Map<String, Object> properties) {
final TableModel model = new PropertiesTableModel(properties);
table.setModel(model);
table.getSelectionModel().setSelectionMode(
ListSelectionModel.SINGLE_SELECTION);
model.addTableModelListener(table);
}
示例8: subscribeActual
import javax.swing.table.TableModel; //导入方法依赖的package包/类
@Override
protected void subscribeActual(Observer<? super TableModelEvent> observer) {
TableModel w = widget;
TableModelEventConsumer aec = new TableModelEventConsumer(observer, w);
observer.onSubscribe(aec);
w.addTableModelListener(aec);
if (aec.get() == null) {
aec.onDispose(w);
}
}
示例9: installFor
import javax.swing.table.TableModel; //导入方法依赖的package包/类
public static void installFor(JTable table, JPopupMenu popupMenu, int column) {
removeOldHeaderMouseListener(table);
TableModel model = table.getModel();
model.addTableModelListener(new HeaderCheckBoxHandler(table));
table.getTableHeader().addMouseListener(new HeaderMouseListener(popupMenu, column));
TableCellRenderer r = new HeaderRenderer(table.getTableHeader(), popupMenu, column);
table.getColumnModel().getColumn(column).setHeaderRenderer(r);
TableCellRenderer leftAlign = new LeftAlignHeaderRenderer();
for (int i = 0; i < table.getColumnCount(); i++) {
if (i != column) {
table.getColumnModel().getColumn(i).setHeaderRenderer(leftAlign);
}
}
}
示例10: setModel
import javax.swing.table.TableModel; //导入方法依赖的package包/类
public void setModel(TableModel model) {
this.model = model;
model.addTableModelListener(this);
}
示例11: watch
import javax.swing.table.TableModel; //导入方法依赖的package包/类
public void watch(TableModel m)
{
m.addTableModelListener(listener);
}