use of javax.swing.table.DefaultTableColumnModel in project pcgen by PCGen.
the class SkillPointTableModel method initializeTable.
public static void initializeTable(JTable table) {
table.setAutoCreateColumnsFromModel(false);
JTableHeader header = table.getTableHeader();
TableColumnModel columns = new DefaultTableColumnModel();
TableCellRenderer headerRenderer = header.getDefaultRenderer();
columns.addColumn(Utilities.createTableColumn(0, "in_level", headerRenderer, false));
columns.addColumn(Utilities.createTableColumn(1, "in_class", headerRenderer, true));
TableColumn remainCol = Utilities.createTableColumn(2, "in_iskRemain", headerRenderer, false);
remainCol.setCellRenderer(new BoldNumberRenderer());
columns.addColumn(remainCol);
columns.addColumn(Utilities.createTableColumn(3, "in_gained", headerRenderer, false));
table.setDefaultRenderer(Integer.class, new TableCellUtilities.AlignRenderer(SwingConstants.CENTER));
table.setColumnModel(columns);
table.setFocusable(false);
header.setReorderingAllowed(false);
header.setResizingAllowed(false);
}
use of javax.swing.table.DefaultTableColumnModel in project processdash by dtuma.
the class WBSTabPanel method addTab.
/** Add a tab to the tab panel
* @param tabName The name to display on the tab
* @param columnNames The columns to display when this tab is selected
*/
public int addTab(String tabName, String[] columnIDs, String[] columnNames, boolean isEditable, boolean isProtected) {
DataTableModel tableModel = (DataTableModel) dataTable.getModel();
TableColumnModel columnModel = new DefaultTableColumnModel();
for (int i = 0; i < columnIDs.length; i++) {
if (columnIDs[i] == null)
continue;
else if (TEAM_MEMBER_PLAN_TIMES_ID.equals(columnIDs[i])) {
tableModel.addTeamMemberPlanTimes(columnModel);
isProtected = true;
} else if (TEAM_MEMBER_ACTUAL_TIMES_ID.equals(columnIDs[i])) {
tableModel.addTeamMemberActualTimes(columnModel);
isProtected = true;
} else if (CUSTOM_COLUMNS_ID.equals(columnIDs[i])) {
customColumnsTab = columnModel;
customColumnInsertPosDelta = columnIDs.length - i - 1;
tableModel.addCustomColumns(columnModel);
} else {
try {
TableColumn tableColumn = new DataTableColumn(tableModel, columnIDs[i]);
if (columnNames != null && columnNames[i] != null)
// maybe change the name of the column
tableColumn.setHeaderValue(columnNames[i]);
columnModel.addColumn(tableColumn);
} catch (IllegalArgumentException e) {
//ignore columns not found
}
}
}
int tabIndex = addTab(tabName, columnModel, new TabProperties(isEditable, isProtected));
return tabIndex;
}
use of javax.swing.table.DefaultTableColumnModel in project processdash by dtuma.
the class BoundDefectTable method resyncTable.
private void resyncTable() {
selectAll.setSelected(true);
TableColumnModel tcm = new DefaultTableColumnModel();
for (int col = 0; col < data.getColumnCount(); col++) if (data.hasData(col))
tcm.addColumn(tableColumns[col]);
table.setColumnModel(tcm);
ErrorData error = data.getErrorData();
if (error != null) {
messageLabel.setText(error.getError());
messageLabel.setForeground(map.getErrorColor(error));
cardLayout.first(this);
} else {
messageLabel.setText(null);
cardLayout.last(this);
}
}
use of javax.swing.table.DefaultTableColumnModel in project knime-core by knime.
the class RankNodeDialog method initRankTableBox.
private Box initRankTableBox() {
Box columnTableBox = Box.createVerticalBox();
columnTableBox.setBorder(new TitledBorder("Ranking Attributes"));
m_rankTableModel = new DefaultTableModel(new String[] { "Attribute", "Order" }, 0);
DefaultTableColumnModel columnModel = new DefaultTableColumnModel();
m_rankJTable = new JTable(m_rankTableModel, columnModel);
m_rankJTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
m_rankJTable.setCellSelectionEnabled(false);
m_rankJTable.setColumnSelectionAllowed(false);
m_rankJTable.getTableHeader().setReorderingAllowed(false);
m_rankJTable.setRowSelectionAllowed(true);
TableColumn colColumn = new TableColumn();
colColumn.setHeaderValue("Column");
colColumn.setCellRenderer(new DataColumnSpecTableCellRenderer());
m_rankColEditorModel = new DefaultComboBoxModel<DataColumnSpec>();
m_rankColEditor = new JComboBox<DataColumnSpec>(m_rankColEditorModel);
m_rankColEditor.setRenderer(new DataColumnSpecListCellRenderer());
m_rankColEditor.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
// TODO Auto-generated method stub
if (!m_availableEdited) {
DataColumnSpec colSpec = (DataColumnSpec) e.getItem();
int state = e.getStateChange();
if (state == ItemEvent.SELECTED && m_rankJTable.isEditing()) {
m_availableCols.remove(colSpec);
removeItemGroupColEditor(colSpec);
// removeItemRankColEditor(colSpec);
m_rankCols.add(colSpec);
} else if (state == ItemEvent.DESELECTED && m_rankJTable.isEditing()) {
m_rankCols.remove(colSpec);
if (!m_rankCols.contains(colSpec)) {
add2AvailableList(colSpec);
addItemGroupColEditor(colSpec);
}
}
}
}
});
colColumn.setCellEditor(new DefaultCellEditor(m_rankColEditor));
TableColumn orderColumn = new TableColumn(1);
orderColumn.setHeaderValue("Order");
// combo box for order column
JComboBox<String> orderColumnEditor = new JComboBox<String>();
orderColumnEditor.addItem("Ascending");
orderColumnEditor.addItem("Descending");
orderColumn.setCellEditor(new DefaultCellEditor(orderColumnEditor));
columnModel.addColumn(colColumn);
columnModel.addColumn(orderColumn);
JScrollPane scrollPane = new JScrollPane(m_rankJTable);
scrollPane.setPreferredSize(m_rankJTable.getPreferredSize());
columnTableBox.add(scrollPane);
columnTableBox.setSize(scrollPane.getSize());
return columnTableBox;
}
use of javax.swing.table.DefaultTableColumnModel in project cytoscape-impl by cytoscape.
the class PreferencesDialog method initTable.
private void initTable() {
DefaultTableColumnModel cm = new DefaultTableColumnModel();
for (int i = 0; i < PreferenceTableModel.columnHeader.length; i++) {
DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
renderer.setHorizontalAlignment(PreferenceTableModel.alignment[i]);
TableColumn Column = new TableColumn(i, PreferenceTableModel.columnWidth[i], renderer, null);
Column.setIdentifier(PreferenceTableModel.columnHeader[i]);
cm.addColumn(Column);
}
prefsTable.setColumnModel(cm);
prefsTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
prefsTable.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2 && !e.isConsumed()) {
e.consume();
if (prefsTable.getSelectedRow() >= 0 && modifyPropBtn.isEnabled())
modifyPropBtn.doClick();
}
}
});
}
Aggregations