Search in sources :

Example 66 with TableColumnModel

use of javax.swing.table.TableColumnModel in project jdk8u_jdk by JetBrains.

the class XMBeanAttributes method updateColumnWidth.

private void updateColumnWidth(int col1Width, int col2Width) {
    TableColumnModel colModel = getColumnModel();
    //Get the column at index pColumn, and set its preferred width.
    col1Width = col1Width * 7;
    col2Width = col2Width * 7;
    if (col1Width + col2Width < (int) getPreferredScrollableViewportSize().getWidth())
        col2Width = (int) getPreferredScrollableViewportSize().getWidth() - col1Width;
    colModel.getColumn(NAME_COLUMN).setPreferredWidth(50);
}
Also used : TableColumnModel(javax.swing.table.TableColumnModel)

Example 67 with TableColumnModel

use of javax.swing.table.TableColumnModel in project jabref by JabRef.

the class StyleSelectDialog method setupTable.

private void setupTable() {
    styles = new BasicEventList<>();
    EventList<OOBibStyle> sortedStyles = new SortedList<>(styles);
    tableModel = (DefaultEventTableModel<OOBibStyle>) GlazedListsSwing.eventTableModelWithThreadProxyList(sortedStyles, new StyleTableFormat());
    table = new JTable(tableModel);
    TableColumnModel cm = table.getColumnModel();
    cm.getColumn(0).setPreferredWidth(100);
    cm.getColumn(1).setPreferredWidth(200);
    cm.getColumn(2).setPreferredWidth(80);
    selectionModel = (DefaultEventSelectionModel<OOBibStyle>) GlazedListsSwing.eventSelectionModelWithThreadProxyList(sortedStyles);
    table.setSelectionModel(selectionModel);
    table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.addMouseListener(new MouseAdapter() {

        @Override
        public void mousePressed(MouseEvent mouseEvent) {
            if (mouseEvent.isPopupTrigger()) {
                tablePopup(mouseEvent);
            }
        }

        @Override
        public void mouseReleased(MouseEvent mouseEvent) {
            if (mouseEvent.isPopupTrigger()) {
                tablePopup(mouseEvent);
            }
        }
    });
    selectionModel.getSelected().addListEventListener(new EntrySelectionListener());
}
Also used : OOBibStyle(org.jabref.logic.openoffice.OOBibStyle) MouseEvent(java.awt.event.MouseEvent) JTable(javax.swing.JTable) SortedList(ca.odell.glazedlists.SortedList) MouseAdapter(java.awt.event.MouseAdapter) TableColumnModel(javax.swing.table.TableColumnModel)

Example 68 with TableColumnModel

use of javax.swing.table.TableColumnModel in project jabref by JabRef.

the class SearchResultFrame method setWidths.

/**
     * Set column widths according to which field is shown, and lock icon columns
     * to a suitable width.
     */
private void setWidths() {
    TableColumnModel cm = entryTable.getColumnModel();
    for (int i = 0; i < PAD + FIELDS.length; i++) {
        switch(i) {
            case FILE_COL:
            case URL_COL:
                cm.getColumn(i).setPreferredWidth(GUIGlobals.WIDTH_ICON_COL);
                cm.getColumn(i).setMinWidth(GUIGlobals.WIDTH_ICON_COL);
                cm.getColumn(i).setMaxWidth(GUIGlobals.WIDTH_ICON_COL);
                break;
            case DATABASE_COL:
                {
                    int width = InternalBibtexFields.getFieldLength(FieldName.AUTHOR);
                    cm.getColumn(i).setPreferredWidth(width);
                    break;
                }
            default:
                {
                    int width = InternalBibtexFields.getFieldLength(FIELDS[i - PAD]);
                    cm.getColumn(i).setPreferredWidth(width);
                    break;
                }
        }
    }
}
Also used : TableColumnModel(javax.swing.table.TableColumnModel)

Example 69 with TableColumnModel

use of javax.swing.table.TableColumnModel in project JMRI by JMRI.

the class LocoDataModel method setColumnToHoldEStopButton.

void setColumnToHoldEStopButton(JTable slotTable, int column) {
    TableColumnModel tcm = slotTable.getColumnModel();
    // install the button renderers & editors in this column
    ButtonRenderer buttonRenderer = new ButtonRenderer();
    tcm.getColumn(column).setCellRenderer(buttonRenderer);
    TableCellEditor buttonEditor = new ButtonEditor(new JButton()) {

        @Override
        public void mousePressed(MouseEvent e) {
            stopCellEditing();
        }
    };
    tcm.getColumn(column).setCellEditor(buttonEditor);
    // ensure the table rows, columns have enough room for buttons
    slotTable.setRowHeight(new JButton("  " + getValueAt(1, column)).getPreferredSize().height);
    slotTable.getColumnModel().getColumn(column).setPreferredWidth(new JButton("  " + getValueAt(1, column)).getPreferredSize().width);
}
Also used : ButtonEditor(jmri.util.table.ButtonEditor) MouseEvent(java.awt.event.MouseEvent) JButton(javax.swing.JButton) TableColumnModel(javax.swing.table.TableColumnModel) TableCellEditor(javax.swing.table.TableCellEditor) ButtonRenderer(jmri.util.table.ButtonRenderer)

Example 70 with TableColumnModel

use of javax.swing.table.TableColumnModel in project JMRI by JMRI.

the class LocoDataModel method setColumnToHoldButton.

void setColumnToHoldButton(JTable slotTable, int column) {
    TableColumnModel tcm = slotTable.getColumnModel();
    // install the button renderers & editors in this column
    ButtonRenderer buttonRenderer = new ButtonRenderer();
    tcm.getColumn(column).setCellRenderer(buttonRenderer);
    TableCellEditor buttonEditor = new ButtonEditor(new JButton());
    tcm.getColumn(column).setCellEditor(buttonEditor);
    // ensure the table rows, columns have enough room for buttons
    slotTable.setRowHeight(new JButton("  " + getValueAt(1, column)).getPreferredSize().height);
    slotTable.getColumnModel().getColumn(column).setPreferredWidth(new JButton("  " + getValueAt(1, column)).getPreferredSize().width);
}
Also used : ButtonEditor(jmri.util.table.ButtonEditor) JButton(javax.swing.JButton) TableColumnModel(javax.swing.table.TableColumnModel) TableCellEditor(javax.swing.table.TableCellEditor) ButtonRenderer(jmri.util.table.ButtonRenderer)

Aggregations

TableColumnModel (javax.swing.table.TableColumnModel)168 TableColumn (javax.swing.table.TableColumn)66 JTable (javax.swing.JTable)34 JScrollPane (javax.swing.JScrollPane)31 JButton (javax.swing.JButton)30 BoxLayout (javax.swing.BoxLayout)24 TableCellEditor (javax.swing.table.TableCellEditor)23 ButtonEditor (jmri.util.table.ButtonEditor)23 ButtonRenderer (jmri.util.table.ButtonRenderer)23 JLabel (javax.swing.JLabel)22 JPanel (javax.swing.JPanel)22 ActionEvent (java.awt.event.ActionEvent)20 ActionListener (java.awt.event.ActionListener)16 FlowLayout (java.awt.FlowLayout)15 Border (javax.swing.border.Border)13 Iterator (java.util.Iterator)12 Set (java.util.Set)12 JTableHeader (javax.swing.table.JTableHeader)12 TableCellRenderer (javax.swing.table.TableCellRenderer)12 Container (java.awt.Container)10