Search in sources :

Example 76 with DefaultCellEditor

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));
}
Also used : JComboBox(javax.swing.JComboBox) TableColumn(javax.swing.table.TableColumn) DefaultCellEditor(javax.swing.DefaultCellEditor)

Example 77 with DefaultCellEditor

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()));
}
Also used : GroupAction(net.imagej.updater.GroupAction) FileObject(net.imagej.updater.FileObject) DefaultCellEditor(javax.swing.DefaultCellEditor)

Example 78 with DefaultCellEditor

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);
}
Also used : JComboBox(javax.swing.JComboBox) DefaultCellEditor(javax.swing.DefaultCellEditor) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer)

Example 79 with DefaultCellEditor

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;
        }
    };
}
Also used : JComboBox(javax.swing.JComboBox) Color(java.awt.Color) DefaultCellEditor(javax.swing.DefaultCellEditor)

Example 80 with DefaultCellEditor

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);
        }
    };
}
Also used : Journaled(com.ramussoft.common.journal.Journaled) Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) JComboBox(javax.swing.JComboBox) Pin(com.ramussoft.pb.idef.elements.PaintSector.Pin) MetadataGetter(com.ramussoft.gui.qualifier.table.MetadataGetter) JTable(javax.swing.JTable) DefaultCellEditor(javax.swing.DefaultCellEditor)

Aggregations

DefaultCellEditor (javax.swing.DefaultCellEditor)184 JComboBox (javax.swing.JComboBox)116 JTable (javax.swing.JTable)59 TableColumn (javax.swing.table.TableColumn)59 ArrayList (java.util.ArrayList)47 TableCellEditor (javax.swing.table.TableCellEditor)35 JScrollPane (javax.swing.JScrollPane)33 JPanel (javax.swing.JPanel)26 ActionEvent (java.awt.event.ActionEvent)25 DefaultTableCellRenderer (javax.swing.table.DefaultTableCellRenderer)23 ProxyColumn (us.mn.state.dot.tms.client.proxy.ProxyColumn)23 JLabel (javax.swing.JLabel)22 JTextField (javax.swing.JTextField)22 Component (java.awt.Component)21 DefaultTableModel (javax.swing.table.DefaultTableModel)21 Dimension (java.awt.Dimension)17 ActionListener (java.awt.event.ActionListener)16 JButton (javax.swing.JButton)16 JCheckBox (javax.swing.JCheckBox)16 TableCellRenderer (javax.swing.table.TableCellRenderer)15