Search in sources :

Example 21 with TableColumn

use of javax.swing.table.TableColumn in project SE2017_4_tuna by SE-admin.

the class Frame4 method setTableCellRenderer.

private void setTableCellRenderer(JTable table, TableCellRenderer renderer) {
    TableColumnModel columnModel = table.getColumnModel();
    int columnCount = columnModel.getColumnCount();
    for (int i = 0; i < columnCount; i++) {
        TableColumn column = columnModel.getColumn(i);
        column.setCellRenderer(renderer);
    }
}
Also used : TableColumnModel(javax.swing.table.TableColumnModel) TableColumn(javax.swing.table.TableColumn)

Example 22 with TableColumn

use of javax.swing.table.TableColumn in project SE2017_4_tuna by SE-admin.

the class MainFrame method setTableCellRenderer.

private void setTableCellRenderer(JTable table, TableCellRenderer renderer) {
    TableColumnModel columnModel = table.getColumnModel();
    int columnCount = columnModel.getColumnCount();
    for (int i = 0; i < columnCount; i++) {
        TableColumn column = columnModel.getColumn(i);
        column.setCellRenderer(renderer);
    }
}
Also used : TableColumnModel(javax.swing.table.TableColumnModel) TableColumn(javax.swing.table.TableColumn)

Example 23 with TableColumn

use of javax.swing.table.TableColumn in project intellij-community by JetBrains.

the class SwingUpdaterUI method askUser.

@Override
public Map<String, ValidationResult.Option> askUser(List<ValidationResult> validationResults) throws OperationCancelledException {
    Map<String, ValidationResult.Option> result = new HashMap<>();
    try {
        SwingUtilities.invokeAndWait(() -> {
            boolean proceed = true;
            for (ValidationResult result1 : validationResults) {
                if (result1.options.contains(ValidationResult.Option.NONE)) {
                    proceed = false;
                    break;
                }
            }
            final JDialog dialog = new JDialog(myFrame, TITLE, true);
            dialog.setLayout(new BorderLayout());
            dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
            JPanel buttonsPanel = new JPanel();
            buttonsPanel.setBorder(BUTTONS_BORDER);
            buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.X_AXIS));
            buttonsPanel.add(Box.createHorizontalGlue());
            JButton cancelButton = new JButton(CANCEL_BUTTON_TITLE);
            cancelButton.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    isCancelled.set(true);
                    myCancelButton.setEnabled(false);
                    dialog.setVisible(false);
                }
            });
            buttonsPanel.add(cancelButton);
            if (proceed) {
                JButton proceedButton = new JButton(PROCEED_BUTTON_TITLE);
                proceedButton.addActionListener(new ActionListener() {

                    public void actionPerformed(ActionEvent e) {
                        dialog.setVisible(false);
                    }
                });
                buttonsPanel.add(proceedButton);
                dialog.getRootPane().setDefaultButton(proceedButton);
            } else {
                dialog.getRootPane().setDefaultButton(cancelButton);
            }
            JTable table = new JTable();
            table.setCellSelectionEnabled(true);
            table.setDefaultEditor(ValidationResult.Option.class, new MyCellEditor());
            table.setDefaultRenderer(Object.class, new MyCellRenderer());
            MyTableModel model = new MyTableModel(validationResults);
            table.setModel(model);
            for (int i = 0; i < table.getColumnModel().getColumnCount(); i++) {
                TableColumn each = table.getColumnModel().getColumn(i);
                each.setPreferredWidth(MyTableModel.getColumnWidth(i, new Dimension(600, 400).width));
            }
            String message = "<html>Some conflicts were found in the installation area.<br><br>";
            if (proceed) {
                message += "Please select desired solutions from the " + MyTableModel.COLUMNS[MyTableModel.OPTIONS_COLUMN_INDEX] + " column and press " + PROCEED_BUTTON_TITLE + ".<br>" + "If you do not want to proceed with the update, please press " + CANCEL_BUTTON_TITLE + ".</html>";
            } else {
                message += "Some of the conflicts below do not have a solution, so the patch cannot be applied.<br>" + "Press " + CANCEL_BUTTON_TITLE + " to exit.</html>";
            }
            JLabel label = new JLabel(message);
            label.setBorder(LABEL_BORDER);
            dialog.add(label, BorderLayout.NORTH);
            dialog.add(new JScrollPane(table), BorderLayout.CENTER);
            dialog.add(buttonsPanel, BorderLayout.SOUTH);
            dialog.getRootPane().setBorder(FRAME_BORDER);
            dialog.setSize(new Dimension(600, 400));
            dialog.setLocationRelativeTo(null);
            dialog.setVisible(true);
            result.putAll(model.getResult());
        });
    } catch (InterruptedException | InvocationTargetException e) {
        throw new RuntimeException(e);
    }
    checkCancelled();
    return result;
}
Also used : ActionEvent(java.awt.event.ActionEvent) TableColumn(javax.swing.table.TableColumn) InvocationTargetException(java.lang.reflect.InvocationTargetException) ActionListener(java.awt.event.ActionListener)

Example 24 with TableColumn

use of javax.swing.table.TableColumn in project zaproxy by zaproxy.

the class TableColumnManager method columnMoved.

@Override
public void columnMoved(TableColumnModelEvent e) {
    if (e.getFromIndex() == e.getToIndex()) {
        return;
    }
    // A table column has been moved one position to the left or right
    // in the view of the table so we need to update the manager to
    // track the new location
    int index = e.getToIndex();
    TableColumn column = columnModel.getColumn(index);
    allColumns.remove(column);
    if (index == 0) {
        allColumns.add(0, column);
    } else {
        index--;
        TableColumn visibleColumn = columnModel.getColumn(index);
        int insertionColumn = allColumns.indexOf(visibleColumn);
        allColumns.add(insertionColumn + 1, column);
    }
}
Also used : TableColumn(javax.swing.table.TableColumn)

Example 25 with TableColumn

use of javax.swing.table.TableColumn in project zaproxy by zaproxy.

the class HttpPanelParamTableView method setEditable.

@Override
public void setEditable(boolean editable) {
    if (isEditable != editable) {
        if (isEditable) {
            table.getColumnModel().removeColumn(table.getColumnModel().getColumn(3));
        } else {
            TableColumn column = new TableColumn(3, 150, new ComboBoxCellRenderer(comboBoxAddIns), new DefaultCellEditor(comboBoxAddIns));
            column.setPreferredWidth(150);
            column.setMaxWidth(150);
            table.addColumn(column);
        }
        isEditable = editable;
        httpPanelTabularModel.setEditable(editable);
    }
}
Also used : TableColumn(javax.swing.table.TableColumn) DefaultCellEditor(javax.swing.DefaultCellEditor)

Aggregations

TableColumn (javax.swing.table.TableColumn)215 TableColumnModel (javax.swing.table.TableColumnModel)66 JTable (javax.swing.JTable)44 JScrollPane (javax.swing.JScrollPane)37 JPanel (javax.swing.JPanel)31 TableCellRenderer (javax.swing.table.TableCellRenderer)30 BoxLayout (javax.swing.BoxLayout)25 JLabel (javax.swing.JLabel)24 Component (java.awt.Component)21 ActionEvent (java.awt.event.ActionEvent)20 FlowLayout (java.awt.FlowLayout)16 ActionListener (java.awt.event.ActionListener)16 DefaultCellEditor (javax.swing.DefaultCellEditor)16 JButton (javax.swing.JButton)16 DefaultTableCellRenderer (javax.swing.table.DefaultTableCellRenderer)15 JComboBox (javax.swing.JComboBox)14 Dimension (java.awt.Dimension)13 DefaultTableModel (javax.swing.table.DefaultTableModel)12 JTableHeader (javax.swing.table.JTableHeader)12 XTableColumnModel (jmri.util.swing.XTableColumnModel)12