use of javax.swing.table.DefaultTableColumnModel in project pcgen by PCGen.
the class AbilityTreeTableModel method initializeTreeTable.
/**
* Initialise a tree table that will be backed by an AbilityTreeTableModel.
* @param treeTable The tree table to be initialized.
*/
public static void initializeTreeTable(JTreeTable treeTable) {
//$NON-NLS-1$ //$NON-NLS-2$
treeTable.getTree().putClientProperty("JTree.lineStyle", "Horizontal");
treeTable.setAutoCreateColumnsFromModel(false);
DefaultTableColumnModel model = new DefaultTableColumnModel();
TableCellRenderer headerRenderer = treeTable.getTableHeader().getDefaultRenderer();
model.addColumn(Utilities.createTableColumn(0, "in_featSelectedAbilities", headerRenderer, //$NON-NLS-1$
true));
model.addColumn(//$NON-NLS-1$
Utilities.createTableColumn(//$NON-NLS-1$
1, //$NON-NLS-1$
"in_featChoices", headerRenderer, true));
treeTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
treeTable.setColumnModel(model);
treeTable.setDefaultRenderer(String.class, new TableCellUtilities.AlignRenderer(SwingConstants.LEFT, true));
}
use of javax.swing.table.DefaultTableColumnModel in project pcgen by PCGen.
the class EquipmentModel method initializeTreeTable.
public static void initializeTreeTable(JTreeTable treeTable) {
treeTable.getTree().setRowHeight(0);
treeTable.setFocusable(false);
treeTable.getTree().putClientProperty("JTree.lineStyle", "Horizontal");
normFont = treeTable.getFont();
headerFont = FontManipulation.title(normFont);
biggerFont = FontManipulation.title(FontManipulation.xxlarge(normFont));
lessFont = FontManipulation.less(normFont);
treeTable.setAutoCreateColumnsFromModel(false);
{
DefaultTableColumnModel model = new DefaultTableColumnModel();
CellRenderer renderer = new CellRenderer();
TableColumn column = new TableColumn(0);
column.setResizable(true);
model.addColumn(column);
model.addColumn(createFixedColumn(1, 75, renderer));
model.addColumn(createFixedColumn(2, 75, renderer));
model.addColumn(createFixedColumn(3, 50, renderer));
model.addColumn(createFixedColumn(4, 50, renderer));
treeTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
treeTable.setColumnModel(model);
treeTable.getTableHeader().setResizingAllowed(false);
}
treeTable.setTreeCellRenderer(new TreeRenderer());
}
use of javax.swing.table.DefaultTableColumnModel in project pcgen by PCGen.
the class CompanionInfoTab method initComponents.
private void initComponents() {
{
DefaultTableColumnModel model = new DefaultTableColumnModel();
TableColumn column = new TableColumn(0);
column.setResizable(true);
model.addColumn(column);
column = new TableColumn(1, 120, new ButtonCellRenderer(), null);
column.setMaxWidth(120);
column.setResizable(false);
model.addColumn(column);
companionsTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
companionsTable.getTableHeader().setResizingAllowed(false);
companionsTable.setAutoCreateColumnsFromModel(false);
companionsTable.setColumnModel(model);
}
companionsTable.setIntercellSpacing(new Dimension(0, 0));
companionsTable.setFocusable(false);
companionsTable.setRowHeight(23);
companionsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
setLeftComponent(new JScrollPane(companionsTable));
JPanel rightPane = new JPanel(new BorderLayout());
infoPane.setOpaque(false);
infoPane.setEditable(false);
infoPane.setFocusable(true);
//$NON-NLS-1$
infoPane.setContentType("text/html");
rightPane.add(new JScrollPane(infoPane), BorderLayout.CENTER);
JPanel buttonPane = new JPanel(new FlowLayout());
buttonPane.add(loadButton);
rightPane.add(buttonPane, BorderLayout.SOUTH);
setRightComponent(rightPane);
}
use of javax.swing.table.DefaultTableColumnModel in project intellij-community by JetBrains.
the class JTableWrapper method packColumns.
private void packColumns() {
DefaultTableColumnModel colModel = (DefaultTableColumnModel) myTable.getColumnModel();
int[] colMinWidths = new int[myColumns.length];
for (int iColumn = 0; iColumn < myColumns.length; iColumn++) {
TableColumn col = colModel.getColumn(iColumn);
colMinWidths[iColumn] = col.getMinWidth();
if (!myColumns[iColumn].needPack()) {
col.setWidth(col.getMinWidth());
continue;
}
// Get width of column header
TableCellRenderer renderer = col.getHeaderRenderer();
if (renderer == null) {
renderer = myTable.getTableHeader().getDefaultRenderer();
}
Component comp = renderer.getTableCellRendererComponent(myTable, col.getHeaderValue(), false, false, 0, 0);
int colWidth = comp.getPreferredSize().width;
for (int iRow = 0; iRow < myTable.getRowCount(); iRow++) {
renderer = myTable.getCellRenderer(iRow, iColumn);
comp = renderer.getTableCellRendererComponent(myTable, myTable.getValueAt(iRow, iColumn), false, false, iRow, iColumn);
colWidth = Math.max(colWidth, comp.getPreferredSize().width);
}
colWidth += 2 * COLUMN_HEADER_MARGIN_WIDTH;
col.setMaxWidth(colWidth);
col.setMinWidth(colWidth);
}
for (int iColumn = 0; iColumn < myColumns.length; iColumn++) {
TableColumn col = colModel.getColumn(iColumn);
col.setMinWidth(colMinWidths[iColumn]);
}
}
use of javax.swing.table.DefaultTableColumnModel in project processdash by dtuma.
the class TaskScheduleDialog method createFlatColumnModel.
private TableColumnModel createFlatColumnModel() {
DefaultTableColumnModel result = new DefaultTableColumnModel();
int extraWidth = 0;
for (int i = 0; i < treeColumnModel.getColumnCount(); i++) {
TableColumn c = treeColumnModel.getColumn(i);
switch(c.getModelIndex()) {
case EVTaskList.TASK_COLUMN:
case EVTaskList.NODE_TYPE_COLUMN:
case EVTaskList.PLAN_TIME_COLUMN:
case EVTaskList.PLAN_DTIME_COLUMN:
//case EVTaskList.ACT_DTIME_COLUMN:
case EVTaskList.PLAN_DATE_COLUMN:
case EVTaskList.REPLAN_DATE_COLUMN:
case EVTaskList.FORECAST_DATE_COLUMN:
case EVTaskList.MILESTONE_COLUMN:
case EVTaskList.LABELS_COLUMN:
case EVTaskList.NOTES_COLUMN:
case EVTaskList.DEPENDENCIES_COLUMN:
case EVTaskList.PCT_SPENT_COLUMN:
result.addColumn(TableUtils.cloneTableColumn(c));
break;
default:
extraWidth += c.getPreferredWidth();
break;
}
}
TableColumn c = result.getColumn(0);
c.setPreferredWidth(c.getWidth() + extraWidth);
return result;
}
Aggregations