use of javax.swing.DefaultCellEditor in project jsoar by soartech.
the class SyntaxPatternComponent method resetStyleNames.
public void resetStyleNames(Set<String> styleNames) {
TableColumn styleColumn = tblCaptureGroups.getColumnModel().getColumn(1);
JComboBox<String> comboBox = new JComboBox<>();
comboBox.addPopupMenuListener(new ExpandingWidthComboBoxListener(true, false));
// comboBox.setPrototypeDisplayValue("Use this for width because we need a fixed width");//will use this string to set max width of the combo box
comboBox.setMaximumSize(comboBox.getPreferredSize());
for (String name : styleNames) {
comboBox.addItem(name);
}
styleColumn.setCellEditor(new DefaultCellEditor(comboBox));
}
use of javax.swing.DefaultCellEditor in project imagej-ui-swing by imagej.
the class FileTable method getCellEditor.
@Override
public TableCellEditor getCellEditor(final int row, final int col) {
final FileObject file = getFile(row);
// As we follow FileTableModel, 1st column is filename
if (col == NAME_COLUMN)
return super.getCellEditor(row, col);
final Set<GroupAction> actions = files.getValidActions(Collections.singleton(file));
return new DefaultCellEditor(new JComboBox<>(actions.toArray()));
}
use of javax.swing.DefaultCellEditor in project Dr-TIM by jkcuk.
the class TableRenderDemo method setUpSportColumn.
public void setUpSportColumn(JTable table, TableColumn sportColumn) {
// Set up the editor for the sport cells.
JComboBox<String> comboBox = new JComboBox<String>();
comboBox.addItem("Snowboarding");
comboBox.addItem("Rowing");
comboBox.addItem("Knitting");
comboBox.addItem("Speed reading");
comboBox.addItem("Pool");
comboBox.addItem("None of the above");
sportColumn.setCellEditor(new DefaultCellEditor(comboBox));
// Set up tool tips for the sport cells.
DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
renderer.setToolTipText("Click for combo box");
sportColumn.setCellRenderer(renderer);
}
use of javax.swing.DefaultCellEditor in project ramus by Vitaliy-Yakovchuk.
the class ColorAttributePlugin method getTableCellEditor.
@Override
public TableCellEditor getTableCellEditor(Engine engine, AccessRules rules, Attribute attribute) {
final JComboBox box = new JComboBox();
box.setRenderer(comboBoxRenderer);
box.addItem(Color.white);
box.addItem(Color.green);
box.addItem(Color.blue);
box.addItem(Color.red);
box.addItem(Color.yellow);
box.addItem(Color.cyan);
box.addItem(Color.magenta);
box.addItem(Color.orange);
box.addItem(Color.pink);
box.addItem(Color.lightGray);
box.addItem(Color.gray);
box.addItem(Color.darkGray);
box.addItem(Color.black);
return new DefaultCellEditor(box) {
@Override
public boolean stopCellEditing() {
if (box.getSelectedItem() instanceof Color)
return super.stopCellEditing();
return false;
}
};
}
use of javax.swing.DefaultCellEditor in project ramus by Vitaliy-Yakovchuk.
the class LineStyleAttributePlugin method getTableCellEditor.
@Override
public TableCellEditor getTableCellEditor(final Engine engine, final AccessRules rules, final Attribute attribute) {
final JComboBox box = new JComboBox();
box.setRenderer(comboBoxRenderer);
for (Stroke stroke : LineStyleChooser.getStrokes()) {
box.addItem(stroke);
}
return new DefaultCellEditor(box) {
private Pin pin;
@Override
public boolean stopCellEditing() {
if (box.getSelectedItem() instanceof Stroke) {
((Journaled) engine).startUserTransaction();
apply((BasicStroke) box.getSelectedItem(), pin);
return super.stopCellEditing();
}
return false;
}
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
pin = (Pin) ((MetadataGetter) table).getMetadata();
return super.getTableCellEditorComponent(table, value, isSelected, row, column);
}
};
}
Aggregations