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());
}
}
});
}
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);
}
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);
}
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");
}
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();
}
}
Aggregations