Search in sources :

Example 16 with DefaultTableColumnModel

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);
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) DefaultTableColumnModel(javax.swing.table.DefaultTableColumnModel) JTableHeader(javax.swing.table.JTableHeader) TableColumnModel(javax.swing.table.TableColumnModel) DefaultTableColumnModel(javax.swing.table.DefaultTableColumnModel) TableColumn(javax.swing.table.TableColumn) TableCellUtilities(pcgen.gui2.util.table.TableCellUtilities)

Example 17 with DefaultTableColumnModel

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;
}
Also used : DefaultTableColumnModel(javax.swing.table.DefaultTableColumnModel) TableColumnModel(javax.swing.table.TableColumnModel) DefaultTableColumnModel(javax.swing.table.DefaultTableColumnModel) TableColumn(javax.swing.table.TableColumn)

Example 18 with DefaultTableColumnModel

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);
    }
}
Also used : DefaultTableColumnModel(javax.swing.table.DefaultTableColumnModel) TableColumnModel(javax.swing.table.TableColumnModel) DefaultTableColumnModel(javax.swing.table.DefaultTableColumnModel) ErrorData(net.sourceforge.processdash.ui.lib.binding.ErrorData)

Example 19 with DefaultTableColumnModel

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;
}
Also used : JScrollPane(javax.swing.JScrollPane) DataColumnSpecListCellRenderer(org.knime.core.node.util.DataColumnSpecListCellRenderer) ItemEvent(java.awt.event.ItemEvent) DefaultTableColumnModel(javax.swing.table.DefaultTableColumnModel) JComboBox(javax.swing.JComboBox) DefaultTableModel(javax.swing.table.DefaultTableModel) JComboBox(javax.swing.JComboBox) Box(javax.swing.Box) JCheckBox(javax.swing.JCheckBox) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString) TitledBorder(javax.swing.border.TitledBorder) TableColumn(javax.swing.table.TableColumn) DefaultCellEditor(javax.swing.DefaultCellEditor) DataColumnSpec(org.knime.core.data.DataColumnSpec) JTable(javax.swing.JTable) DataColumnSpecTableCellRenderer(org.knime.core.node.util.DataColumnSpecTableCellRenderer) ItemListener(java.awt.event.ItemListener)

Example 20 with DefaultTableColumnModel

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();
            }
        }
    });
}
Also used : MouseEvent(java.awt.event.MouseEvent) DefaultTableColumnModel(javax.swing.table.DefaultTableColumnModel) MouseAdapter(java.awt.event.MouseAdapter) TableColumn(javax.swing.table.TableColumn) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer)

Aggregations

DefaultTableColumnModel (javax.swing.table.DefaultTableColumnModel)25 TableColumn (javax.swing.table.TableColumn)18 TableCellRenderer (javax.swing.table.TableCellRenderer)11 TableColumnModel (javax.swing.table.TableColumnModel)8 Component (java.awt.Component)6 JTableHeader (javax.swing.table.JTableHeader)6 JTable (javax.swing.JTable)5 DefaultTableCellRenderer (javax.swing.table.DefaultTableCellRenderer)5 JScrollPane (javax.swing.JScrollPane)4 DefaultTableModel (javax.swing.table.DefaultTableModel)4 Color (java.awt.Color)3 GridBagConstraints (java.awt.GridBagConstraints)3 LineBorder (javax.swing.border.LineBorder)3 Insets (java.awt.Insets)2 ComponentAdapter (java.awt.event.ComponentAdapter)2 ComponentEvent (java.awt.event.ComponentEvent)2 MouseAdapter (java.awt.event.MouseAdapter)2 MouseEvent (java.awt.event.MouseEvent)2 DecimalFormat (java.text.DecimalFormat)2 TableCellUtilities (pcgen.gui2.util.table.TableCellUtilities)2