use of javax.swing.table.TableCellRenderer in project vcell by virtualcell.
the class StyleTable method createPlainTableHeaderRenderer.
/**
* Create plain table header cell renderer
*/
public static TableCellRenderer createPlainTableHeaderRenderer(final Color color) {
return new TableCellRenderer() {
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
JLabel comp = new JLabel(value.toString(), JLabel.LEFT);
comp.setBackground(color);
comp.setOpaque(true);
comp.setBorder(new EmptyBorder(1, 5, 1, 1));
return comp;
}
};
}
use of javax.swing.table.TableCellRenderer in project vcell by virtualcell.
the class ResultDisplayPanel method getRestultTable.
public JTable getRestultTable() {
if (table == null) {
table = new JTable();
// set table model
tableModel = getBestParameterTableModel();
// set table model
table.setModel(tableModel);
table.setCellSelectionEnabled(true);
table.addMouseListener(evtHandler);
// set table renderer
// double precision 6 digits
TableCellRenderer tableRenderer = new NumericTableCellRenderer();
for (int i = 0; i < tableModel.getColumnCount(); i++) {
TableColumn column = table.getColumnModel().getColumn(i);
column.setCellRenderer(tableRenderer);
}
}
return table;
}
use of javax.swing.table.TableCellRenderer in project vcell by virtualcell.
the class GroupableTableHeader method createPlainTableHeaderRenderer.
public static TableCellRenderer createPlainTableHeaderRenderer(final Color color) {
return new TableCellRenderer() {
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
JLabel comp = new JLabel(value.toString(), JLabel.LEFT);
comp.setForeground(Color.black);
comp.setBackground(color);
comp.setOpaque(true);
comp.setBorder(new LineBorder(Color.WHITE, 1));
comp.setFont(VirtualFrapLoader.defaultFont);
comp.setHorizontalAlignment(SwingConstants.CENTER);
return comp;
}
};
}
use of javax.swing.table.TableCellRenderer in project vcell by virtualcell.
the class GroupableTableHeaderUI method getHeaderHeight.
/**
* Calculate and return the height of the header.
* @return Header Height
*/
private int getHeaderHeight() {
int height = 0;
GroupableTableColumnModel columnModel = (GroupableTableColumnModel) header.getColumnModel();
for (int column = 0; column < columnModel.getColumnCount(); column++) {
TableColumn aColumn = columnModel.getColumn(column);
TableCellRenderer renderer = aColumn.getHeaderRenderer();
if (renderer == null) {
renderer = header.getDefaultRenderer();
}
Component comp = renderer.getTableCellRendererComponent(header.getTable(), aColumn.getHeaderValue(), false, false, -1, column);
int cHeight = comp.getPreferredSize().height;
Iterator<ColumnGroup> iter = columnModel.getColumnGroups(aColumn);
if (iter != null) {
while (iter.hasNext()) {
ColumnGroup cGroup = (ColumnGroup) iter.next();
cHeight += cGroup.getSize(header.getTable()).height;
}
}
height = Math.max(height, cHeight);
}
return height;
}
use of javax.swing.table.TableCellRenderer in project vcell by virtualcell.
the class GroupableTableHeaderUI method paintCell.
/**
* Paint group column cell.
* @param g Graphics context
* @param cellRect Rectangle that the cell with be painted in
* @param cGroup Current column group
*/
private void paintCell(Graphics g, Rectangle cellRect, ColumnGroup cGroup) {
TableCellRenderer renderer = cGroup.getHeaderRenderer();
Component component = renderer.getTableCellRendererComponent(header.getTable(), cGroup.getHeaderValue(), false, false, -1, -1);
rendererPane.add(component);
rendererPane.paintComponent(g, component, header, cellRect.x, cellRect.y, cellRect.width, cellRect.height, true);
}
Aggregations