本文整理汇总了Java中javax.swing.table.TableColumn.getHeaderValue方法的典型用法代码示例。如果您正苦于以下问题:Java TableColumn.getHeaderValue方法的具体用法?Java TableColumn.getHeaderValue怎么用?Java TableColumn.getHeaderValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.table.TableColumn
的用法示例。
在下文中一共展示了TableColumn.getHeaderValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mouseClicked
import javax.swing.table.TableColumn; //导入方法依赖的package包/类
@Override
public void mouseClicked(MouseEvent e) {
JTableHeader header = (JTableHeader) e.getSource();
JTable table = header.getTable();
TableColumnModel columnModel = table.getColumnModel();
int vci = columnModel.getColumnIndexAtX(e.getX());
int mci = table.convertColumnIndexToModel(vci);
if (mci == targetColumnIndex) {
if (SwingUtilities.isLeftMouseButton(e)) {
TableColumn column = columnModel.getColumn(vci);
Object v = column.getHeaderValue();
boolean b = Status.DESELECTED.equals(v);
TableModel m = table.getModel();
for (int i = 0; i < m.getRowCount(); i++) {
m.setValueAt(b, i, mci);
}
column.setHeaderValue(b ? Status.SELECTED : Status.DESELECTED);
} else if (SwingUtilities.isRightMouseButton(e)) {
if (popupMenu != null) {
popupMenu.show(table, e.getX(), 0);
}
}
}
}
示例2: copyValues
import javax.swing.table.TableColumn; //导入方法依赖的package包/类
public void copyValues(TableColumn base) {
modelIndex = base.getModelIndex();
identifier = base.getIdentifier();
width = base.getWidth();
minWidth = base.getMinWidth();
setPreferredWidth(base.getPreferredWidth());
maxWidth = base.getMaxWidth();
headerRenderer = base.getHeaderRenderer();
headerValue = base.getHeaderValue();
cellRenderer = base.getCellRenderer();
cellEditor = base.getCellEditor();
isResizable = base.getResizable();
}
示例3: tableChanged
import javax.swing.table.TableColumn; //导入方法依赖的package包/类
@Override
public void tableChanged(TableModelEvent e) {
if (e.getType() == TableModelEvent.UPDATE && e.getColumn() == 0) {
int mci = 0;
int vci = table.convertColumnIndexToView(mci);
TableColumn column = table.getColumnModel().getColumn(vci);
Object title = column.getHeaderValue();
if (!Status.INDETERMINATE.equals(title)) {
column.setHeaderValue(Status.INDETERMINATE);
} else {
int selected = 0, deselected = 0;
TableModel m = table.getModel();
for (int i = 0; i < m.getRowCount(); i++) {
if (Boolean.TRUE.equals(m.getValueAt(i, mci))) {
selected++;
} else {
deselected++;
}
}
if (selected == 0) {
column.setHeaderValue(Status.DESELECTED);
} else if (deselected == 0) {
column.setHeaderValue(Status.SELECTED);
} else {
return;
}
}
table.getTableHeader().repaint();
}
}