TableColumn col=table.getColumnModel().getTableColumn(colNumber); col.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChanged(PropertyChangeEvent e) { // has the column width changed ? } });
private void initListeners() { // install a listener to cause the whole table to repaint when a column is resized. we do this because the extended grid // lines may need to be repainted. this could be cleaned up, but for now, it works fine. PropertyChangeListener listener = createTableColumnWidthListener(); for (int i = 0; i < fTable.getColumnModel().getColumnCount(); i++) { fTable.getColumnModel().getColumn(i).addPropertyChangeListener(listener); } }
private void addColumn(int columnIndex, TableColumn aColumn) { if (aColumn == null) { throw new IllegalArgumentException("Object is null"); } tableColumns.add(columnIndex, aColumn); aColumn.addPropertyChangeListener(this); recalcWidthCache(); // post columnAdded event notification fireColumnAdded(new TableColumnModelEvent(this, columnIndex, columnIndex)); }
public void addColumn(TableColumn column) { super.addColumn(column); final int index = column.getModelIndex(); column.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (PROP_COLUMN_WIDTH.equals(evt.getPropertyName())) { int oldWidth = ((Integer)evt.getOldValue()).intValue(); int newWidth = ((Integer)evt.getNewValue()).intValue(); fireColumnWidthChanged(index, oldWidth, newWidth); } } }); }
@Override public void addColumn(TableColumn aColumn) { // if this method is called, column number is updated from the outside. // Most likely, a new column set is added after all previous columns have been removed. // In this case we consider that all the columns are shown // and we have to resynchronize with supreclass content synchWithSuperclass(); // add the column aColumn.removePropertyChangeListener(widthListener); aColumn.addPropertyChangeListener(widthListener); allColumns.add(aColumn); hidingSelectionDialog = null; super.addColumn(aColumn); }
revalidateScrollBar(); } else if ("treeColumnIndex".equals(evt.getPropertyName())) { // NOI18N treeTable.getColumnModel().getColumn(((TreeTable)treeTable).getTreeColumnIndex()).addPropertyChangeListener(listener); } else if ("column_moved".equals(evt.getPropertyName())) { // NOI18N int from = ((Integer)evt.getOldValue()).intValue();
/** * Constructs model column, bounded with view's column. * * @param aName * @param aOnRender * @param aOnSelect * @param aReadOnly * @param aView * @param aEditor */ public ModelColumn(String aName, JSObject aOnRender, JSObject aOnSelect, boolean aReadOnly, ModelWidget aView, ModelWidget aEditor) { super(); name = aName; onRender = aOnRender; onSelect = aOnSelect; readOnly = aReadOnly; view = aView; super.setCellRenderer(aView); editor = aEditor; super.setCellEditor(editor); super.setWidth(50); tempWidth = super.getWidth(); tempMinWidth = super.getMinWidth(); tempMaxWidth = super.getMaxWidth(); tempResizable = super.getResizable(); tempMoveable = moveable; super.addPropertyChangeListener((PropertyChangeEvent evt) -> { changeSupport.firePropertyChange(evt.getPropertyName(), evt.getOldValue(), evt.getNewValue()); }); }
public static void createPropertyChangeListeners(ActionContext actionContext){ Thing self = (Thing) actionContext.get("self"); TableColumn parent = (TableColumn) actionContext.get("parent"); for(Thing child : self.getChilds()){ PropertyChangeListener obj = (PropertyChangeListener) child.doAction("create", actionContext); if(obj != null){ parent.addPropertyChangeListener(obj); } } }
/** * Adds striping to the background of the given {@link JTable}. The actual * striping is installed on the containing {@link JScrollPane}'s * {@link JViewport}, so if this table is not added to a {@code JScrollPane} * , then no stripes will be painted. This method can be called before the * given table is added to a scroll pane, though, as a * {@link PropertyChangeListener} will be installed to handle "ancestor" * changes. * * @param table the table to paint row stripes for. */ public static void setViewPortListeners(JTable table) { table.addPropertyChangeListener("ancestor", createAncestorPropertyChangeListener(table)); // Install a listener to cause the whole table to repaint when a column // is resized. We do this because the extended grid lines may need to be // repainted. This could be cleaned up, but for now, it works fine. for (int i = 0; i < table.getColumnModel().getColumnCount(); i++) { table.getColumnModel().getColumn(i).addPropertyChangeListener(createAncestorPropertyChangeListener(table)); table.getColumnModel().addColumnModelListener(createTableColumnModelListener(table)); } }
private void installColumn(TableColumn column) { this.column = column; column.addPropertyChangeListener(getColumnListener()); updateFromColumnHeader(column.getHeaderValue()); // #429-swing: actionCommand must be string if (column.getIdentifier() != null) { setActionCommand(column.getIdentifier().toString()); } boolean visible = (column instanceof TableColumnExt) ? ((TableColumnExt) column).isVisible() : true; updateFromColumnVisible(visible); }
private void installColumn(TableColumn column) { this.column = column; column.addPropertyChangeListener(getColumnListener()); updateFromColumnHeader(column.getHeaderValue()); // #429-swing: actionCommand must be string if (column.getIdentifier() != null) { setActionCommand(column.getIdentifier().toString()); } boolean visible = (column instanceof TableColumnExt) ? ((TableColumnExt) column).isVisible() : true; updateFromColumnVisible(visible); }
private void installColumn(TableColumn column) { this.column = column; column.addPropertyChangeListener(getColumnListener()); updateFromColumnHeader(column.getHeaderValue()); // #429-swing: actionCommand must be string if (column.getIdentifier() != null) { setActionCommand(column.getIdentifier().toString()); } boolean visible = (column instanceof TableColumnExt) ? ((TableColumnExt) column).isVisible() : true; updateFromColumnVisible(visible); }
private void installColumn(TableColumn column) { this.column = column; column.addPropertyChangeListener(getColumnListener()); updateFromColumnHeader(column.getHeaderValue()); // #429-swing: actionCommand must be string if (column.getIdentifier() != null) { setActionCommand(column.getIdentifier().toString()); } boolean visible = (column instanceof TableColumnExt) ? ((TableColumnExt) column).isVisible() : true; updateFromColumnVisible(visible); }
public final void setTableColumn(TableColumn aColumn) { if (tableColumn != null) { tableColumn.removePropertyChangeListener(columnListener); } if (aColumn == null && tableColumn != null) { minWidth = tableColumn.getMinWidth(); maxWidth = tableColumn.getMaxWidth(); if (tableColumn.getHeaderValue() instanceof String) { title = (String) tableColumn.getHeaderValue(); } } tableColumn = aColumn; if (tableColumn != null) { tableColumn.addPropertyChangeListener(columnListener); } }
private void installColumn(TableColumn column) { this.column = column; column.addPropertyChangeListener(getColumnListener()); updateFromColumnHeader(column.getHeaderValue()); // #429-swing: actionCommand must be string if (column.getIdentifier() != null) { setActionCommand(column.getIdentifier().toString()); } boolean visible = (column instanceof TableColumnExt) ? ((TableColumnExt) column).isVisible() : true; updateFromColumnVisible(visible); }
throw new IllegalStateException("null TableColumn objects are not allowed in EventTableColumnModel"); newColumn.addPropertyChangeListener(this); fireColumnAdded(new TableColumnModelEvent(this, 0, getColumnCount() - 1)); newColumn.addPropertyChangeListener(this);
throw new IllegalStateException("null TableColumn objects are not allowed in EventTableColumnModel"); newColumn.addPropertyChangeListener(this); fireColumnAdded(new TableColumnModelEvent(this, 0, getColumnCount() - 1)); newColumn.addPropertyChangeListener(this);
/** * Creates a new model that contains the {@link TableColumn} objects from * the given <code>source</code>. Changes to the <code>source</code> are * reflected in this model. */ public EventTableColumnModel(EventList<T> source) { setSelectionModel(createSelectionModel()); setColumnMargin(1); invalidateWidthCache(); setColumnSelectionAllowed(false); // lock the source list for reading since we want to prevent writes // from occurring until we fully initialize this EventTableColumnModel source.getReadWriteLock().readLock().lock(); try { // ensure all of the TableColumns are non-null for (int i = 0, n = source.size(); i < n; i++) { if (source.get(i) == null) throw new IllegalStateException("null TableColumn objects are not allowed in EventTableColumnModel"); } // start listening to each of the TableColumns for property changes that may resize the table header for (int i = 0, n = source.size(); i < n; i++) source.get(i).addPropertyChangeListener(this); disposeSwingThreadSource = !GlazedListsSwing.isSwingThreadProxyList(source); swingThreadSource = disposeSwingThreadSource ? GlazedListsSwing.swingThreadProxyList(source) : (TransformedList<T, T>) source; swingThreadSource.addListEventListener(this); } finally { source.getReadWriteLock().readLock().unlock(); } }
/** * Creates a new model that contains the {@link TableColumn} objects from * the given <code>source</code>. Changes to the <code>source</code> are * reflected in this model. */ public EventTableColumnModel(EventList<T> source) { setSelectionModel(createSelectionModel()); setColumnMargin(1); invalidateWidthCache(); setColumnSelectionAllowed(false); // lock the source list for reading since we want to prevent writes // from occurring until we fully initialize this EventTableColumnModel source.getReadWriteLock().readLock().lock(); try { // ensure all of the TableColumns are non-null for (int i = 0, n = source.size(); i < n; i++) { if (source.get(i) == null) throw new IllegalStateException("null TableColumn objects are not allowed in EventTableColumnModel"); } // start listening to each of the TableColumns for property changes that may resize the table header for (int i = 0, n = source.size(); i < n; i++) source.get(i).addPropertyChangeListener(this); disposeSwingThreadSource = !GlazedListsSwing.isSwingThreadProxyList(source); swingThreadSource = disposeSwingThreadSource ? GlazedListsSwing.swingThreadProxyList(source) : (TransformedList<T, T>) source; swingThreadSource.addListEventListener(this); } finally { source.getReadWriteLock().readLock().unlock(); } }
/** * Creates a new model that contains the {@link TableColumn} objects from * the given <code>source</code>. Changes to the <code>source</code> are * reflected in this model. */ public EventTableColumnModel(EventList<T> source) { setSelectionModel(createSelectionModel()); setColumnMargin(1); invalidateWidthCache(); setColumnSelectionAllowed(false); // lock the source list for reading since we want to prevent writes // from occurring until we fully initialize this EventTableColumnModel source.getReadWriteLock().readLock().lock(); try { // ensure all of the TableColumns are non-null for (int i = 0, n = source.size(); i < n; i++) { if (source.get(i) == null) throw new IllegalStateException("null TableColumn objects are not allowed in EventTableColumnModel"); } // start listening to each of the TableColumns for property changes that may resize the table header for (int i = 0, n = source.size(); i < n; i++) source.get(i).addPropertyChangeListener(this); disposeSwingThreadSource = !GlazedListsSwing.isSwingThreadProxyList(source); swingThreadSource = disposeSwingThreadSource ? GlazedListsSwing.swingThreadProxyList(source) : (TransformedList<T, T>) source; swingThreadSource.addListEventListener(this); } finally { source.getReadWriteLock().readLock().unlock(); } }