本文整理汇总了Java中javax.swing.event.TableColumnModelEvent类的典型用法代码示例。如果您正苦于以下问题:Java TableColumnModelEvent类的具体用法?Java TableColumnModelEvent怎么用?Java TableColumnModelEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TableColumnModelEvent类属于javax.swing.event包,在下文中一共展示了TableColumnModelEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: columnAdded
import javax.swing.event.TableColumnModelEvent; //导入依赖的package包/类
@Override
public void columnAdded(TableColumnModelEvent e) {
LinesTableColumn type = getColumnType(e.getToIndex());
TableColumn column = getColumnModel().getColumn(e.getToIndex());
switch (type) {
case COLOR:
column.setMaxWidth(25);
break;
case CLASS:
column.setPreferredWidth(90);
break;
case STATION:
column.setPreferredWidth(90);
break;
case ALGORITHM:
column.setPreferredWidth(100);
break;
}
super.columnAdded(e);
}
示例2: columnMoved
import javax.swing.event.TableColumnModelEvent; //导入依赖的package包/类
public void columnMoved(TableColumnModelEvent event)
{
if(isEmpty() || getEventSource() != null) {
return;
}
setEventSource(event.getSource());
int columnIndex = event.getFromIndex();
int newIndex = event.getToIndex();
Collection<TableColumnModel> models = values();
for (TableColumnModel model : models) {
if(model == getEventSource())
continue;
model.moveColumn(columnIndex, newIndex);
}
if(columnIndex != newIndex) {
TableColumnSynchronizer column = columns.get(columnIndex);
columns.remove(columnIndex);
columns.add(newIndex, column);
}
setEventSource(null);
}
示例3: columnAdded
import javax.swing.event.TableColumnModelEvent; //导入依赖的package包/类
public void columnAdded(TableColumnModelEvent event)
{
super.columnAdded(event);
TableColumn column = getColumnModel().getColumn(event.getToIndex());
column.setCellRenderer(cellRenderer);
AlignerTree aligner = getAlignerTree();
if(synchronizer != null &&
aligner != null) {
synchronizer.add(aligner);
synchronizer = null;
}
TableCellRenderer r = column.getHeaderRenderer();
if(r instanceof TreeHeaderRenderer) {
JTree tree = ((TreeHeaderRenderer)r).getTree();
if(!(tree instanceof AlignerTree) &&
aligner != null)
aligner.addTree((NameTree)tree);
resizeAndRepaint();
}
}
示例4: columnRemoved
import javax.swing.event.TableColumnModelEvent; //导入依赖的package包/类
public void columnRemoved(TableColumnModelEvent event)
{
AlignerTree atree = getAlignerTree();
if(atree != null) {
List<JTree> renderers = atree.getTrees();
Enumeration<TableColumn> e =
getColumnModel().getColumns();
while(e.hasMoreElements()) {
TableCellRenderer r =
e.nextElement().getHeaderRenderer();
if(renderers.contains(r))
renderers.remove(r);
}
for(JTree tree: renderers) {
atree.removeTree((NameTree)tree);
}
renderers.clear();
}
super.columnRemoved(event);
}
示例5: moveColumn
import javax.swing.event.TableColumnModelEvent; //导入依赖的package包/类
public void moveColumn(final int columnIndex, final int newIndex) {
if (columnIndex < 0 || columnIndex >= getColumnCount()
|| newIndex < 0 || newIndex > getColumnCount()) {
throw new IllegalArgumentException(Messages.getString("swing.79")); //$NON-NLS-1$
}
if (columnIndex != newIndex) {
TableColumn firstColumn = getColumn(columnIndex);
tableColumns.remove(columnIndex);
tableColumns.add(newIndex, firstColumn);
boolean oldIsSelected = selectionModel.isSelectedIndex(columnIndex);
selectionModel.removeIndexInterval(columnIndex, columnIndex);
selectionModel.insertIndexInterval(newIndex, 1, true);
if (oldIsSelected) {
selectionModel.addSelectionInterval(newIndex, newIndex);
} else {
selectionModel.removeSelectionInterval(newIndex, newIndex);
}
}
fireColumnMoved(new TableColumnModelEvent(this, columnIndex, newIndex));
}
示例6: moveColumn
import javax.swing.event.TableColumnModelEvent; //导入依赖的package包/类
@Override
public void moveColumn(int viewFrom, int viewTo) {
// viewToModelMap
columnMap.get(viewToModelMap.get(viewFrom)).setOrder(viewTo);
if(viewFrom < viewTo) {
for (int i = viewFrom + 1; i <= viewTo; i++) {
columnMap.get(viewToModelMap.get(i)).setOrder(i-1);
}
reorderViewColumns(true);
}else if(viewFrom > viewTo){
for (int i = viewFrom-1; i >= viewTo; i--) {
columnMap.get(viewToModelMap.get(i)).setOrder(i+1);
}
reorderViewColumns(true);
}else{
//no change
}
this.fireColumnMoved(new TableColumnModelEvent(this, viewFrom, viewTo));
}
示例7: moveColumn
import javax.swing.event.TableColumnModelEvent; //导入依赖的package包/类
public void moveColumn(int fromIndex, int toIndex) {
if (!MainFrame.getInstance().canNavigateAway())
return;
MainFrame.getInstance().updateDesignationDisplay();
TableColumn from = columnList.get(fromIndex);
TableColumn to = columnList.get(toIndex);
columnList.set(fromIndex, to);
to.setModelIndex(fromIndex);
columnList.set(toIndex, from);
from.setModelIndex(toIndex);
orderUpdate();
for (TableColumnModelListener w : new ArrayList<TableColumnModelListener>(watchers)) {
w.columnMoved(new TableColumnModelEvent(this, fromIndex, toIndex));
}
}
示例8: columnAdded
import javax.swing.event.TableColumnModelEvent; //导入依赖的package包/类
@Override
public void columnAdded(TableColumnModelEvent e) {
int minWidth;
final int index = e.getToIndex();
switch (index) {
case 0:
case 1:
minWidth = 60;
break;
default:
minWidth = 80;
}
TableColumnModel columnModel = (TableColumnModel) e.getSource();
columnModel.getColumn(index).setPreferredWidth(minWidth);
columnModel.getColumn(index).setCellRenderer(new RightAlignmentTableCellRenderer());
}
示例9: addColumn
import javax.swing.event.TableColumnModelEvent; //导入依赖的package包/类
/** Copy of addColumn(TableColumn) with an index specifying where to add the new column */
private void addColumn(TableColumn aColumn, int index) {
if (aColumn == null) {
throw new IllegalArgumentException("Object is null");
}
tableColumns.insertElementAt(aColumn, index);
aColumn.addPropertyChangeListener(this);
//invalidateWidthCache();
totalColumnWidth = -1;
// Post columnAdded event notification
fireColumnAdded(new TableColumnModelEvent(this, 0, index));
}
示例10: columnMoved
import javax.swing.event.TableColumnModelEvent; //导入依赖的package包/类
@Override
public void columnMoved(TableColumnModelEvent e) {
int from = e.getFromIndex();
int to = e.getToIndex();
if(from == to) {
return;
}
table.getTableHeader().getColumnModel().getColumn(from).setModelIndex(from);
table.getTableHeader().getColumnModel().getColumn(to).setModelIndex(to);
tableModel.moveColumn(from, to);
}
示例11: columnAdded
import javax.swing.event.TableColumnModelEvent; //导入依赖的package包/类
@Override
public void columnAdded(TableColumnModelEvent e) {
super.columnAdded(e);
// bigger default size
TableColumn column = getColumnModel().getColumn(getColumnModel().getColumnCount() - 1);
column.setPreferredWidth(COLUMN_WIDTH);
}
示例12: columnMoved
import javax.swing.event.TableColumnModelEvent; //导入依赖的package包/类
/** Necessary to properly stopping the editing when a column is moved (dragged). */
@Override
public void columnMoved(final TableColumnModelEvent e) {
if (isEditing()) {
cellEditor.stopCellEditing();
}
super.columnMoved(e);
}
示例13: columnMoved
import javax.swing.event.TableColumnModelEvent; //导入依赖的package包/类
/**
* Overridden to fix
* //http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4330950:
*/
@Override
public void columnMoved(TableColumnModelEvent e) {
if (isEditing()) {
cellEditor.stopCellEditing();
}
super.columnMoved(e);
}
示例14: columnAdded
import javax.swing.event.TableColumnModelEvent; //导入依赖的package包/类
/**
* Maps {@code JTable.columnAdded(TableColumnModelEvent)} through queue
*/
public void columnAdded(final TableColumnModelEvent tableColumnModelEvent) {
runMapping(new MapVoidAction("columnAdded") {
@Override
public void map() {
((JTable) getSource()).columnAdded(tableColumnModelEvent);
}
});
}
示例15: columnMoved
import javax.swing.event.TableColumnModelEvent; //导入依赖的package包/类
/**
* Maps {@code JTable.columnMoved(TableColumnModelEvent)} through queue
*/
public void columnMoved(final TableColumnModelEvent tableColumnModelEvent) {
runMapping(new MapVoidAction("columnMoved") {
@Override
public void map() {
((JTable) getSource()).columnMoved(tableColumnModelEvent);
}
});
}