use of javax.swing.table.JTableHeader in project knime-core by knime.
the class TableContentView method setShowIconInColumnHeader.
/**
* Sets the property whether or not the icon in the column header
* shall be shown. This typically represents the column's type icon
* (the cell type contained in the column). Sometimes, this is not
* desired (for instance in the data outport view).
* @param show Whether or not this icon should be shown.
*/
public final void setShowIconInColumnHeader(final boolean show) {
if (show != m_isShowIconInColumnHeader) {
m_isShowIconInColumnHeader = show;
JTableHeader header = getTableHeader();
if (header == null) {
return;
}
TableCellRenderer r = header.getDefaultRenderer();
if (r instanceof ColumnHeaderRenderer) {
ColumnHeaderRenderer cr = (ColumnHeaderRenderer) r;
cr.setShowIcon(show);
}
}
}
use of javax.swing.table.JTableHeader in project knime-core by knime.
the class TableRowHeaderView method setFont.
/**
* {@inheritDoc}
*/
@Override
public void setFont(final Font font) {
super.setFont(font);
JTableHeader th = getTableHeader();
if (th != null) {
th.setFont(font);
}
}
use of javax.swing.table.JTableHeader in project knime-core by knime.
the class PreviewTableContentView method onMouseClickInHeader.
/**
* {@inheritDoc}
*/
@Override
protected void onMouseClickInHeader(final MouseEvent e) {
JTableHeader header = getTableHeader();
// get column in which event occurred
int column = header.columnAtPoint(e.getPoint());
if (column < 0) {
return;
}
int modelIndex = convertColumnIndexToModel(column);
firePropertyChange(PROPERTY_SPEC_CHANGED, null, modelIndex);
}
use of javax.swing.table.JTableHeader in project vcell by virtualcell.
the class JSortTable method initSortHeader.
private void initSortHeader() {
JTableHeader header = getTableHeader();
if (header != null) {
header.removeMouseListener(this);
header.addMouseListener(this);
for (int i = 0; i < getColumnCount(); i++) {
header.getColumnModel().getColumn(i).setHeaderRenderer(new SortTableHeaderRenderer(getTableHeader().getDefaultRenderer()));
}
}
}
use of javax.swing.table.JTableHeader in project vcell by virtualcell.
the class SortTableHeaderRenderer method getTableCellRendererComponent.
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
Component c = defaultTableCellRender.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col);
JLabel label = null;
if (c instanceof JLabel) {
label = (JLabel) c;
} else {
label = new JLabel();
label.setText(value.toString());
Border border = null;
if (hasFocus) {
border = UIManager.getBorder("TableHeader.focusCellBorder");
}
if (border == null) {
border = UIManager.getBorder("TableHeader.cellBorder");
}
if (table != null) {
JTableHeader header = table.getTableHeader();
if (header != null) {
Color fgColor = null;
Color bgColor = null;
if (hasFocus) {
fgColor = UIManager.getColor("TableHeader.focusCellForeground");
bgColor = UIManager.getColor("TableHeader.focusCellBackground");
}
if (fgColor == null) {
fgColor = header.getForeground();
}
if (bgColor == null) {
bgColor = header.getBackground();
}
label.setForeground(fgColor);
label.setBackground(bgColor);
label.setFont(header.getFont());
}
}
}
boolean ascending = false;
Icon icon = NOSORTING_ICON;
if (table instanceof JSortTable) {
int columnIndex = -1;
JSortTable sortTable = (JSortTable) table;
SortPreference sortPreference = ((SortTableModel) sortTable.getModel()).getSortPreference();
int modelIndex = sortPreference.getSortedColumnIndex();
if (modelIndex >= 0) {
for (int i = 0; i < table.getColumnModel().getColumnCount(); i++) {
if (table.getColumnModel().getColumn(i).getModelIndex() == modelIndex) {
columnIndex = i;
break;
}
}
ascending = sortPreference.isSortedColumnAscending();
if (col == columnIndex) {
icon = ascending ? ASCENDING_ICON : DECENDING_ICON;
}
}
}
label.setHorizontalTextPosition(JLabel.LEFT);
label.setIcon(icon);
return label;
}
Aggregations