Search in sources :

Example 91 with TableCellEditor

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

the class AlignTablePane method initComponents.

/**
     * Initialize the window
     */
public void initComponents() {
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    alignModel = new AlignModel();
    JTable alignTable = new JTable(alignModel);
    // install a button renderer & editor
    ButtonRenderer buttonRenderer = new ButtonRenderer();
    alignTable.setDefaultRenderer(JButton.class, buttonRenderer);
    TableCellEditor buttonEditor = new ButtonEditor(new JButton());
    alignTable.setDefaultEditor(JButton.class, buttonEditor);
    TableRowSorter<AlignModel> sorter = new TableRowSorter<>(alignModel);
    RowSorterUtil.setSortOrder(sorter, AlignModel.NUMCOL, SortOrder.ASCENDING);
    alignTable.setRowSelectionAllowed(false);
    alignTable.setPreferredScrollableViewportSize(new java.awt.Dimension(580, 80));
    JScrollPane scrollPane = new JScrollPane(alignTable);
    add(scrollPane);
    // status info on bottom
    JPanel p = new JPanel() {

        @Override
        public Dimension getMaximumSize() {
            int height = getPreferredSize().height;
            int width = super.getMaximumSize().width;
            return new Dimension(width, height);
        }
    };
    p.setLayout(new FlowLayout());
    p.add(new JLabel(rb.getString("LabelNumCol")));
    num.setText("" + Engine.instance().getMaxReceiverNumber());
    p.add(num);
    JButton b = new JButton(rb.getString("ButtonSet"));
    b.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            // set number of columns
            Engine.instance().setMaxReceiverNumber(Integer.parseInt(num.getText()));
            // mark modification
            flag.setModifiedFlag(true);
            // resize table
            alignModel.fireTableStructureChanged();
        }
    });
    p.add(b);
    add(p);
    p = new JPanel() {

        @Override
        public Dimension getMaximumSize() {
            int height = getPreferredSize().height;
            int width = super.getMaximumSize().width;
            return new Dimension(width, height);
        }
    };
    p.setLayout(new FlowLayout());
    p.add(new JLabel(rb.getString("LabelVSound")));
    vsound.setText("" + Engine.instance().getVSound());
    p.add(vsound);
    p.add(new JLabel(rb.getString("LabelOffset")));
    offset.setText("" + Engine.instance().getOffset());
    p.add(offset);
    p.add(new JLabel(rb.getString("LabelAlgorithm")));
    p.add(algorithmBox);
    b = new JButton(rb.getString("ButtonSet"));
    b.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            // set number of vsound, offset
            Engine.instance().setOffset(Integer.parseInt(offset.getText()));
            Engine.instance().setVSound(Double.parseDouble(vsound.getText()));
            Engine.instance().setAlgorithm((String) algorithmBox.getSelectedItem());
            // mark modification
            flag.setModifiedFlag(true);
        }
    });
    p.add(b);
    add(p);
    //
    add(loadStore = new jmri.jmrix.rps.swing.LoadStorePanel() {

        // make sure we redisplay if changed
        @Override
        public void load() {
            super.load();
            alignModel.fireTableStructureChanged();
            // modified (to force store of default after load new values)
            flag.setModifiedFlag(true);
        }

        @Override
        public void storeDefault() {
            super.storeDefault();
            // no longer modified after storeDefault
            flag.setModifiedFlag(false);
        }
    });
    // add sound listener
    Engine.instance().addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(java.beans.PropertyChangeEvent e) {
            if (e.getPropertyName().equals("vSound")) {
                // update sound display
                vsound.setText("" + e.getNewValue());
            }
        }
    });
}
Also used : JPanel(javax.swing.JPanel) ButtonEditor(jmri.util.table.ButtonEditor) FlowLayout(java.awt.FlowLayout) PropertyChangeListener(java.beans.PropertyChangeListener) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) TableCellEditor(javax.swing.table.TableCellEditor) TableRowSorter(javax.swing.table.TableRowSorter) JScrollPane(javax.swing.JScrollPane) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) Dimension(java.awt.Dimension) ActionListener(java.awt.event.ActionListener) JTable(javax.swing.JTable) ButtonRenderer(jmri.util.table.ButtonRenderer)

Example 92 with TableCellEditor

use of javax.swing.table.TableCellEditor in project intellij-plugins by JetBrains.

the class OsmorcFacetJAREditorTab method onRemoveAdditionalJarContent.

private void onRemoveAdditionalJarContent() {
    int row = myAdditionalJARContentsTable.convertRowIndexToModel(myAdditionalJARContentsTable.getSelectedRow());
    int editingCol = myAdditionalJARContentsTable.getEditingColumn();
    int editingRow = myAdditionalJARContentsTable.getEditingRow();
    if (editingCol != -1 && editingRow != -1) {
        TableCellEditor editor = myAdditionalJARContentsTable.getCellEditor(editingRow, editingCol);
        editor.cancelCellEditing();
    }
    myAdditionalJARContentsTableModel.deleteAdditionalJARContent(row);
}
Also used : TableCellEditor(javax.swing.table.TableCellEditor)

Example 93 with TableCellEditor

use of javax.swing.table.TableCellEditor in project processdash by dtuma.

the class ProxyJTable method getCellEditor.

@Override
public TableCellEditor getCellEditor(int row, int column) {
    DataColumn dc = ((ProxyDataModel) getModel()).getColumn(column);
    if (dc instanceof ProxySizeColumn) {
        ProxySizeColumn psc = (ProxySizeColumn) dc;
        TableCellEditor result = psc.getCellEditorForRow(row);
        if (result != null)
            return result;
    }
    return super.getCellEditor(row, column);
}
Also used : ProxySizeColumn(teamdash.wbs.columns.ProxySizeColumn) TableCellEditor(javax.swing.table.TableCellEditor)

Example 94 with TableCellEditor

use of javax.swing.table.TableCellEditor in project processdash by dtuma.

the class DataJTable method editingStopped.

@Override
public void editingStopped(ChangeEvent e) {
    // check to see if the value in this cell actually changed.
    boolean valueChanged = false;
    String columnName = null;
    TableCellEditor editor = getCellEditor();
    if (editor != null) {
        Object valueAfterEditing = editor.getCellEditorValue();
        valueChanged = !equal(valueBeforeEditing, valueAfterEditing);
        columnName = getColumnName(getEditingColumn());
    }
    // stop the editing session
    super.editingStopped(e);
    // if the value was changed, notify the UndoList.
    if (valueChanged)
        UndoList.madeChange(DataJTable.this, "Editing value in '" + columnName + "' column");
}
Also used : TableCellEditor(javax.swing.table.TableCellEditor)

Example 95 with TableCellEditor

use of javax.swing.table.TableCellEditor in project frostwire by frostwire.

the class FWAbstractJPanelTableCellRenderer method cancelEdit.

protected void cancelEdit() {
    if (table != null && table.isEditing()) {
        TableCellEditor editor = table.getCellEditor();
        editor.cancelCellEditing();
    }
}
Also used : TableCellEditor(javax.swing.table.TableCellEditor)

Aggregations

TableCellEditor (javax.swing.table.TableCellEditor)129 JButton (javax.swing.JButton)41 ButtonEditor (jmri.util.table.ButtonEditor)33 ButtonRenderer (jmri.util.table.ButtonRenderer)33 TableColumnModel (javax.swing.table.TableColumnModel)24 JTable (javax.swing.JTable)22 ActionEvent (java.awt.event.ActionEvent)21 TableCellRenderer (javax.swing.table.TableCellRenderer)21 TableColumn (javax.swing.table.TableColumn)20 JLabel (javax.swing.JLabel)16 JScrollPane (javax.swing.JScrollPane)16 ActionListener (java.awt.event.ActionListener)15 MouseEvent (java.awt.event.MouseEvent)13 JPanel (javax.swing.JPanel)13 Component (java.awt.Component)11 Dimension (java.awt.Dimension)11 EventObject (java.util.EventObject)10 TableModel (javax.swing.table.TableModel)10 JComponent (javax.swing.JComponent)9 JTextField (javax.swing.JTextField)9