javax.swing.DefaultCellEditor Java Examples

The following examples show how to use javax.swing.DefaultCellEditor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Test6505027.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public Test6505027(JFrame main) {
    Container container = main;
    if (INTERNAL) {
        JInternalFrame frame = new JInternalFrame();
        frame.setBounds(OFFSET, OFFSET, WIDTH, HEIGHT);
        frame.setVisible(true);

        JDesktopPane desktop = new JDesktopPane();
        desktop.add(frame, new Integer(1));

        container.add(desktop);
        container = frame;
    }
    if (TERMINATE) {
        this.table.putClientProperty(KEY, Boolean.TRUE);
    }
    TableColumn column = this.table.getColumn(COLUMNS[1]);
    column.setCellEditor(new DefaultCellEditor(new JComboBox(ITEMS)));

    container.add(BorderLayout.NORTH, new JTextField());
    container.add(BorderLayout.CENTER, new JScrollPane(this.table));
}
 
Example #2
Source File: ContinuousLoadPanel.java    From openAGV with Apache License 2.0 6 votes vote down vote up
private void buildTableModels(TransportOrderData transportOrder) {
  requireNonNull(transportOrder, "transportOrder");

  // Drive orders
  locationsComboBox.removeAllItems();
  operationTypesComboBox.removeAllItems();
  SortedSet<Location> sortedLocationSet = new TreeSet<>(Comparators.objectsByName());
  sortedLocationSet.addAll(objectService.fetchObjects(Location.class));
  for (Location i : sortedLocationSet) {
    locationsComboBox.addItem(i.getReference());
  }
  locationsComboBox.addItemListener((ItemEvent e) -> locationsComboBoxItemStateChanged(e));
  doTable.setModel(new DriveOrderTableModel(transportOrder.getDriveOrders()));
  doTable.setDefaultEditor(TCSObjectReference.class, new DefaultCellEditor(locationsComboBox));
  doTable.setDefaultEditor(String.class, new DefaultCellEditor(operationTypesComboBox));

  // Properties
  propertyTable.setModel(new PropertyTableModel(transportOrder.getProperties()));
}
 
Example #3
Source File: GamedataEditorRenderFactory.java    From gameserver with Apache License 2.0 6 votes vote down vote up
@Override
public TableCellEditor getCellEditor(int row, int column, 
		String columnName, TableModel tableModel, JTable table) {
	if ( "value".equals(columnName) || "default".equals(columnName) ) {
		int modelColIndex = table.convertColumnIndexToModel(column);
		int modelRowIndex = table.convertRowIndexToModel(row);
		Object value =  this.tableModel.getValueAt(modelRowIndex, modelColIndex);
		if ( value instanceof BasicDBList ) {
			MongoDBArrayEditor editor =  new MongoDBArrayEditor();
			editor.setDBObject((BasicDBList)value);
			return editor;
		} else {
			JXTextField field = new JXTextField(value.toString());
			field.setPreferredSize(new Dimension(100, 36));
			field.setBorder(null);
			return new DefaultCellEditor(field);
		}
	}
	return null;
}
 
Example #4
Source File: ContinuousLoadPanel.java    From openAGV with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new instance.
 *
 * @param portalProvider The application's portal provider.
 * @param eventSource Where components can register for events.
 */
@Inject
public ContinuousLoadPanel(SharedKernelServicePortalProvider portalProvider,
                           @ApplicationEventBus EventSource eventSource) {
  this.portalProvider = requireNonNull(portalProvider, "portalProvider");
  this.eventSource = requireNonNull(eventSource, "eventSource");

  initComponents();

  JComboBox<TransportOrderData.Deadline> deadlineComboBox = new JComboBox<>();
  deadlineComboBox.addItem(null);
  for (TransportOrderData.Deadline i : TransportOrderData.Deadline.values()) {
    deadlineComboBox.addItem(i);
  }
  DefaultCellEditor deadlineEditor = new DefaultCellEditor(deadlineComboBox);
  toTable.setDefaultEditor(TransportOrderData.Deadline.class, deadlineEditor);

  toTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
  doTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
}
 
Example #5
Source File: EditPresetDialog.java    From portmapper with GNU General Public License v3.0 6 votes vote down vote up
private Component getPortsPanel() {
    final ActionMap actionMap = app.getContext().getActionMap(this.getClass(), this);

    final JPanel portsPanel = new JPanel(new MigLayout("", "", ""));
    portsPanel.setBorder(
            BorderFactory.createTitledBorder(app.getResourceMap().getString("preset_dialog.ports.title")));

    tableModel = new PortsTableModel(app, ports);
    portsTable = new JTable(tableModel);
    portsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    portsTable.getSelectionModel()
            .addListSelectionListener(e -> firePropertyChange(PROPERTY_PORT_SELECTED, false, isPortSelected()));
    final JComboBox<Protocol> protocolComboBox = new JComboBox<>();
    protocolComboBox.addItem(Protocol.TCP);
    protocolComboBox.addItem(Protocol.UDP);
    portsTable.getColumnModel().getColumn(0).setCellEditor(new DefaultCellEditor(protocolComboBox));

    portsPanel.add(new JScrollPane(portsTable), "spany 3");

    portsPanel.add(new JButton(actionMap.get(ACTION_ADD_PORT)), "wrap");
    portsPanel.add(new JButton(actionMap.get(ACTION_ADD_PORT_RANGE)), "wrap");
    portsPanel.add(new JButton(actionMap.get(ACTION_REMOVE_PORT)), "wrap");

    return portsPanel;
}
 
Example #6
Source File: TableRenderDemo.java    From mars-sim with GNU General Public License v3.0 6 votes vote down vote up
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);
}
 
Example #7
Source File: TableCellEditorFactory.java    From ramus with GNU General Public License v3.0 6 votes vote down vote up
private TableCellEditor createBaseQualifierEditor() {
    List<Qualifier> qualifiers = engine.getQualifiers();
    Collections.sort(qualifiers, new Comparator<Qualifier>() {
        @Override
        public int compare(Qualifier o1, Qualifier o2) {
            return collator.compare(o1.getName(), o2.getName());
        }
    });

    JComboBox box = new JComboBox();

    box.addItem(null);
    for (Qualifier qualifier : qualifiers)
        box.addItem(qualifier);

    return new DefaultCellEditor(box);
}
 
Example #8
Source File: Test6505027.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public Test6505027(JFrame main) {
    Container container = main;
    if (INTERNAL) {
        JInternalFrame frame = new JInternalFrame();
        frame.setBounds(OFFSET, OFFSET, WIDTH, HEIGHT);
        frame.setVisible(true);

        JDesktopPane desktop = new JDesktopPane();
        desktop.add(frame, new Integer(1));

        container.add(desktop);
        container = frame;
    }
    if (TERMINATE) {
        this.table.putClientProperty(KEY, Boolean.TRUE);
    }
    TableColumn column = this.table.getColumn(COLUMNS[1]);
    column.setCellEditor(new DefaultCellEditor(new JComboBox(ITEMS)));

    container.add(BorderLayout.NORTH, new JTextField());
    container.add(BorderLayout.CENTER, new JScrollPane(this.table));
}
 
Example #9
Source File: Test6505027.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public Test6505027(JFrame main) {
    Container container = main;
    if (INTERNAL) {
        JInternalFrame frame = new JInternalFrame();
        frame.setBounds(OFFSET, OFFSET, WIDTH, HEIGHT);
        frame.setVisible(true);

        JDesktopPane desktop = new JDesktopPane();
        desktop.add(frame, new Integer(1));

        container.add(desktop);
        container = frame;
    }
    if (TERMINATE) {
        this.table.putClientProperty(KEY, Boolean.TRUE);
    }
    TableColumn column = this.table.getColumn(COLUMNS[1]);
    column.setCellEditor(new DefaultCellEditor(new JComboBox(ITEMS)));

    container.add(BorderLayout.NORTH, new JTextField());
    container.add(BorderLayout.CENTER, new JScrollPane(this.table));
}
 
Example #10
Source File: Test6505027.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public Test6505027(JFrame main) {
    Container container = main;
    if (INTERNAL) {
        JInternalFrame frame = new JInternalFrame();
        frame.setBounds(OFFSET, OFFSET, WIDTH, HEIGHT);
        frame.setVisible(true);

        JDesktopPane desktop = new JDesktopPane();
        desktop.add(frame, new Integer(1));

        container.add(desktop);
        container = frame;
    }
    if (TERMINATE) {
        this.table.putClientProperty(KEY, Boolean.TRUE);
    }
    TableColumn column = this.table.getColumn(COLUMNS[1]);
    column.setCellEditor(new DefaultCellEditor(new JComboBox(ITEMS)));

    container.add(BorderLayout.NORTH, new JTextField());
    container.add(BorderLayout.CENTER, new JScrollPane(this.table));
}
 
Example #11
Source File: Test6505027.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public Test6505027(JFrame main) {
    Container container = main;
    if (INTERNAL) {
        JInternalFrame frame = new JInternalFrame();
        frame.setBounds(OFFSET, OFFSET, WIDTH, HEIGHT);
        frame.setVisible(true);

        JDesktopPane desktop = new JDesktopPane();
        desktop.add(frame, new Integer(1));

        container.add(desktop);
        container = frame;
    }
    if (TERMINATE) {
        this.table.putClientProperty(KEY, Boolean.TRUE);
    }
    TableColumn column = this.table.getColumn(COLUMNS[1]);
    column.setCellEditor(new DefaultCellEditor(new JComboBox(ITEMS)));

    container.add(BorderLayout.NORTH, new JTextField());
    container.add(BorderLayout.CENTER, new JScrollPane(this.table));
}
 
Example #12
Source File: DesignerTablePanel.java    From nextreports-designer with Apache License 2.0 6 votes vote down vote up
public void updateGroupByItems(int dragRow, int dropRow) {
    MyRow drag_row = (MyRow) model.getObjectForRow(dragRow);
    JComboBox groupByComboDrag = (JComboBox) ((DefaultCellEditor) table.getCellEditor(dragRow, 6)).getComponent();

    MyRow drop_row = (MyRow) model.getObjectForRow(dropRow);
    JComboBox groupByComboDrop = (JComboBox) ((DefaultCellEditor) table.getCellEditor(dropRow, 6)).getComponent();

    String sDrag = (String) groupByComboDrag.getItemAt(0);
    String sDrop = (String) groupByComboDrop.getItemAt(0);

    if ("".equals(sDrag) && !sDrag.equals(sDrop)) {
        groupByComboDrop.insertItemAt("", 0);
        groupByComboDrag.removeItem("");
    }

    if ("".equals(sDrop) && !sDrop.equals(sDrag)) {
        groupByComboDrag.insertItemAt("", 0);
        groupByComboDrop.removeItem("");
    }
}
 
Example #13
Source File: ProjectParametersSetupDialog.java    From mzmine2 with GNU General Public License v2.0 6 votes vote down vote up
private void setupTableModel() {

    tablemodelParameterValues = new ParameterTableModel(dataFiles, parameterValues);
    tableParameterValues.setModel(tablemodelParameterValues);

    for (int columnIndex =
        0; columnIndex < (tablemodelParameterValues.getColumnCount() - 1); columnIndex++) {
      UserParameter<?, ?> parameter = tablemodelParameterValues.getParameter(columnIndex + 1);
      if (parameter instanceof ComboParameter) {
        Object choices[] = ((ComboParameter<?>) parameter).getChoices();
        tableParameterValues.getColumnModel().getColumn(columnIndex + 1)
            .setCellEditor(new DefaultCellEditor(new JComboBox<Object>(choices)));
      }
    }

  }
 
Example #14
Source File: Test6505027.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public Test6505027(JFrame main) {
    Container container = main;
    if (INTERNAL) {
        JInternalFrame frame = new JInternalFrame();
        frame.setBounds(OFFSET, OFFSET, WIDTH, HEIGHT);
        frame.setVisible(true);

        JDesktopPane desktop = new JDesktopPane();
        desktop.add(frame, new Integer(1));

        container.add(desktop);
        container = frame;
    }
    if (TERMINATE) {
        this.table.putClientProperty(KEY, Boolean.TRUE);
    }
    TableColumn column = this.table.getColumn(COLUMNS[1]);
    column.setCellEditor(new DefaultCellEditor(new JComboBox(ITEMS)));

    container.add(BorderLayout.NORTH, new JTextField());
    container.add(BorderLayout.CENTER, new JScrollPane(this.table));
}
 
Example #15
Source File: ExampleSourceConfigurationWizardValueTypeTable.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public TableCellEditor getCellEditor(int row, int column) {
	List<String> usedTypes = new LinkedList<String>();
	for (int i = 0; i < Ontology.VALUE_TYPE_NAMES.length; i++) {
		if ((i != Ontology.ATTRIBUTE_VALUE) && (i != Ontology.FILE_PATH)
				&& (!Ontology.ATTRIBUTE_VALUE_TYPE.isA(i, Ontology.DATE_TIME))) {
			usedTypes.add(Ontology.ATTRIBUTE_VALUE_TYPE.mapIndex(i));
		}
	}
	String[] valueTypes = new String[usedTypes.size()];
	int vCounter = 0;
	for (String type : usedTypes) {
		valueTypes[vCounter++] = type;
	}
	JComboBox<String> typeBox = new JComboBox<>(valueTypes);
	typeBox.setBackground(javax.swing.UIManager.getColor("Table.cellBackground"));
	return new DefaultCellEditor(typeBox);
}
 
Example #16
Source File: NamesAssociationDialog.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
    associationModel.addAlias("...");
    removeButton.setEnabled(true);
    aliasNameScrollPane.repaint();
    int rowIndex = 0;
    for (String aliasName : associationModel.getAliasNames()) {
        if (aliasName.equals("...")) {
            break;
        }
        rowIndex++;
    }
    DefaultCellEditor editor = (DefaultCellEditor) aliasNames.getCellEditor(rowIndex, 0);
    aliasNames.editCellAt(rowIndex, 0);
    final JTextField textField = (JTextField) editor.getComponent();
    textField.requestFocus();
    textField.selectAll();
}
 
Example #17
Source File: DDTable.java    From netbeans with Apache License 2.0 6 votes vote down vote up
DDTable(String[] headers, String titleKey, Editable editable) {
    super(new Object[0][headers.length], headers);
    this.headers = headers;
    this.titleKey = titleKey;
    this.editable = editable;
    this.darkerColor = getBackground().darker();

    setModel(new DDTableModel(headers, editable));
    setColors(editable);
    this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    setIntercellSpacing(new Dimension(margin, margin));
    DefaultCellEditor dce = new DefaultCellEditor(new CellText(this));
    dce.setClickCountToStart(1);
    getColumnModel().getColumn(0).setCellEditor(dce);
    getColumnModel().getColumn(1).setCellEditor(dce);
}
 
Example #18
Source File: QueryParserPaneProvider.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@Override
public void setRangeSearchableFields(Collection<String> rangeSearchableFields) {
  pointRangeQueryTable.setModel(new PointTypesTableModel(rangeSearchableFields));
  pointRangeQueryTable.setShowGrid(true);
  String[] numTypes = Arrays.stream(PointTypesTableModel.NumType.values())
      .map(PointTypesTableModel.NumType::name)
      .toArray(String[]::new);
  JComboBox<String> numTypesCombo = new JComboBox<>(numTypes);
  numTypesCombo.setRenderer((list, value, index, isSelected, cellHasFocus) -> new JLabel(value));
  pointRangeQueryTable.getColumnModel().getColumn(PointTypesTableModel.Column.TYPE.getIndex()).setCellEditor(new DefaultCellEditor(numTypesCombo));
  pointRangeQueryTable.getColumnModel().getColumn(PointTypesTableModel.Column.TYPE.getIndex()).setCellRenderer(
      (table, value, isSelected, hasFocus, row, column) -> new JLabel((String) value)
  );
  pointRangeQueryTable.getColumnModel().getColumn(PointTypesTableModel.Column.FIELD.getIndex()).setPreferredWidth(PointTypesTableModel.Column.FIELD.getColumnWidth());
  pointRangeQueryTable.setPreferredScrollableViewportSize(pointRangeQueryTable.getPreferredSize());

  // set default type to Integer
  for (int i = 0; i < rangeSearchableFields.size(); i++) {
    pointRangeQueryTable.setValueAt(PointTypesTableModel.NumType.INT.name(), i, PointTypesTableModel.Column.TYPE.getIndex());
  }

}
 
Example #19
Source File: InternalUtilities.java    From LGoodDatePicker with MIT License 6 votes vote down vote up
/**
 * setDefaultTableEditorsClicks, This sets the number of clicks required to start the default
 * table editors in the supplied table. Typically you would set the table editors to start after
 * 1 click or 2 clicks, as desired.
 *
 * The default table editors of the table editors that are supplied by the JTable class, for
 * Objects, Numbers, and Booleans. Note, the editor which is used to edit Objects, is the same
 * editor used for editing Strings.
 */
public static void setDefaultTableEditorsClicks(JTable table, int clickCountToStart) {
    TableCellEditor editor;
    editor = table.getDefaultEditor(Object.class);
    if (editor instanceof DefaultCellEditor) {
        ((DefaultCellEditor) editor).setClickCountToStart(clickCountToStart);
    }
    editor = table.getDefaultEditor(Number.class);
    if (editor instanceof DefaultCellEditor) {
        ((DefaultCellEditor) editor).setClickCountToStart(clickCountToStart);
    }
    editor = table.getDefaultEditor(Boolean.class);
    if (editor instanceof DefaultCellEditor) {
        ((DefaultCellEditor) editor).setClickCountToStart(clickCountToStart);
    }
}
 
Example #20
Source File: TableRenderDemo.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public void setUpSportColumn(JTable table, TableColumn sportColumn) {
    // Set up the editor for the sport cells.
    JComboBox comboBox = new JComboBox();
    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);
}
 
Example #21
Source File: CodeSetupPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public TableCellEditor getCellEditor(int row, int column) {
    if(showParamTypes) {
        String paramName = (String) tableModel.getValueAt(row, 0);
        Class type = (column == 2) ? (Class) tableModel.getValueAt(row, 1) : Boolean.class;

        if (Enum.class.isAssignableFrom(type)) {
            JComboBox combo = new JComboBox(type.getEnumConstants());
            return new DefaultCellEditor(combo);
        } else if (type == Boolean.class || type == Boolean.TYPE) {
            JCheckBox cb = new JCheckBox();
            cb.setHorizontalAlignment(JLabel.CENTER);
            cb.setBorderPainted(true);
            return new DefaultCellEditor(cb);
        } else if (paramName.toLowerCase().contains(Constants.PASSWORD)) {
            return new DefaultCellEditor(new JPasswordField());
        }
    }

    return super.getCellEditor(row, column);
}
 
Example #22
Source File: Test6505027.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public Test6505027(JFrame main) {
    Container container = main;
    if (INTERNAL) {
        JInternalFrame frame = new JInternalFrame();
        frame.setBounds(OFFSET, OFFSET, WIDTH, HEIGHT);
        frame.setVisible(true);

        JDesktopPane desktop = new JDesktopPane();
        desktop.add(frame, new Integer(1));

        container.add(desktop);
        container = frame;
    }
    if (TERMINATE) {
        this.table.putClientProperty(KEY, Boolean.TRUE);
    }
    TableColumn column = this.table.getColumn(COLUMNS[1]);
    column.setCellEditor(new DefaultCellEditor(new JComboBox(ITEMS)));

    container.add(BorderLayout.NORTH, new JTextField());
    container.add(BorderLayout.CENTER, new JScrollPane(this.table));
}
 
Example #23
Source File: DriverGUI.java    From openAGV with Apache License 2.0 5 votes vote down vote up
private void initCommAdaptersComboBox(VehicleEntry vehicleEntry,
                                      int rowIndex,
                                      SingleCellEditor adapterCellEditor) {
  final CommAdapterComboBox comboBox = new CommAdapterComboBox();
  commAdapterRegistry.findFactoriesFor(vehicleEntry.getVehicle())
      .forEach(factory -> comboBox.addItem(factory));
  // Set the selection to the attached comm adapter, (The vehicle is already attached to a comm
  // adapter due to auto attachment on startup.)
  comboBox.setSelectedItem(vehicleEntry.getCommAdapterFactory());
  comboBox.setRenderer(new AdapterFactoryCellRenderer());
  comboBox.addPopupMenuListener(new BoundsPopupMenuListener());
  comboBox.addItemListener((ItemEvent evt) -> {
    if (evt.getStateChange() == ItemEvent.DESELECTED) {
      return;
    }

    // If we selected a comm adapter that's already attached, do nothing.
    if (Objects.equals(evt.getItem(), vehicleEntry.getCommAdapterFactory())) {
      LOG.debug("{} is already attached to: {}", vehicleEntry.getVehicleName(), evt.getItem());
      return;
    }

    int reply = JOptionPane.showConfirmDialog(
        null,
        bundle.getString("CommAdapterComboBox.confirmation.driverChange.text"),
        bundle.getString("CommAdapterComboBox.confirmation.driverChange.title"),
        JOptionPane.YES_NO_OPTION);
    if (reply == JOptionPane.NO_OPTION) {
      return;
    }

    attachManager.attachAdapterToVehicle(getSelectedVehicleName(),
                                         (VehicleCommAdapterFactory) comboBox.getSelectedItem());
  });
  adapterCellEditor.setEditorAt(rowIndex, new DefaultCellEditor(comboBox));

  vehicleEntry.addPropertyChangeListener(comboBox);
}
 
Example #24
Source File: TableCellEditorFactory.java    From ramus with GNU General Public License v3.0 5 votes vote down vote up
private TableCellEditor createBooleanAligmentEditor() {
    JComboBox box = new JComboBox();
    box.addItem(null);
    box.addItem(YES);
    box.addItem(NO);

    return new DefaultCellEditor(box);
}
 
Example #25
Source File: RunPortBindingsVisual.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Creates new form RunNetworkVisual
 */
public RunPortBindingsVisual(DockerImageDetail info) {
    initComponents();
    this.info = info;

    addExposedButton.setEnabled(info != null && !info.getExposedPorts().isEmpty());
    portMappingTable.setModel(model);
    UiUtils.configureRowHeight(portMappingTable);

    TableColumn typeColumn = portMappingTable.getColumnModel().getColumn(0);
    JComboBox typeCombo = new JComboBox(ExposedPort.Type.values());
    typeColumn.setCellEditor(new DefaultCellEditor(typeCombo));
    typeColumn.setPreferredWidth(typeColumn.getPreferredWidth() / 2);

    TableColumn portColumn = portMappingTable.getColumnModel().getColumn(2);
    portColumn.setCellRenderer(new CellRenderer("<random>", false));

    TableColumn addressColumn = portMappingTable.getColumnModel().getColumn(3);
    JComboBox addressCombo = new JComboBox(UiUtils.getAddresses(false, false).toArray());
    addressCombo.setEditable(true);
    addressColumn.setCellEditor(new DefaultCellEditor(addressCombo));
    addressColumn.setCellRenderer(new CellRenderer("<any>", false));
    addressColumn.setPreferredWidth(addressColumn.getPreferredWidth() * 2);

    portMappingTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
    model.addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent e) {
            changeSupport.fireChange();
        }
    });
}
 
Example #26
Source File: MdbPropertiesPanelVisual.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private ACPCellEditor createCellEditor(List<ActivationConfigProperty> activationConfigProperties) {
    ACPCellEditor tce = new ACPCellEditor(propertiesTable);
    for (int i = 0; i < activationConfigProperties.size(); i++) {
        ActivationConfigProperty acp = activationConfigProperties.get(i);
        if (acp.getPropertyClass() == String.class) {
            tce.setEditorAt(i, new DefaultCellEditor(new JTextField()));
        } else if (acp.getPropertyClass().isEnum()) {
            Object[] consts = acp.getPropertyClass().getEnumConstants();
            JComboBox comboBox = new JComboBox(consts);
            tce.setEditorAt(i, new DefaultCellEditor(comboBox));
        }
    }
    return tce;
}
 
Example #27
Source File: EditorHelper.java    From javamoney-examples with Apache License 2.0 5 votes vote down vote up
/**
 * This method creates a table cell editor for selectable items.
 *
 * @return A table cell editor for selectable items.
 */
public
static
DefaultCellEditor
createSelectCellEditor()
{
  CheckBox checkbox = new CheckBox();

  checkbox.setHorizontalAlignment(CENTER);

  return new DefaultCellEditor(checkbox);
}
 
Example #28
Source File: KeymapPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
protected void processKeyEvent(KeyEvent e) {

    if (!isEditing())
        super.processKeyEvent(e);
    else {
        Component component = ((DefaultCellEditor) getCellEditor(lastRow, lastColumn)).getComponent();
        component.requestFocus();
        component.dispatchEvent(new KeyEvent(component, e.getID(), e.getWhen(), e.getModifiers(), e.getKeyCode(), e.getKeyChar()));
    }
}
 
Example #29
Source File: SynthTreeUI.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected TreeCellEditor createTreeCellEditor() {
    JTextField tf = new JTextField() {
        @Override
        public String getName() {
            return "Tree.cellEditor";
        }
    };
    DefaultCellEditor editor = new DefaultCellEditor(tf);

    // One click to edit.
    editor.setClickCountToStart(1);
    return editor;
}
 
Example #30
Source File: LuceneDataStoreSearchGUI.java    From gate-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected void updateAnnotationSetsList() {
  String corpusName =
          (corpusToSearchIn.getSelectedItem()
                  .equals(Constants.ENTIRE_DATASTORE))
                  ? null
                  : (String)corpusIds
                          .get(corpusToSearchIn.getSelectedIndex() - 1);
  TreeSet<String> ts = new TreeSet<String>(stringCollator);
  ts.addAll(getAnnotationSetNames(corpusName));
  DefaultComboBoxModel<String> dcbm = new DefaultComboBoxModel<String>(ts.toArray(new String[ts.size()]));
  dcbm.insertElementAt(Constants.ALL_SETS, 0);
  annotationSetsToSearchIn.setModel(dcbm);
  annotationSetsToSearchIn.setSelectedItem(Constants.ALL_SETS);

  // used in the ConfigureStackViewFrame as Annotation type column
  // cell editor
  TreeSet<String> types = new TreeSet<String>(stringCollator);
  types.addAll(getTypesAndFeatures(null, null).keySet());
  // put all annotation types from the datastore
  // combobox used as cell editor
  JComboBox<String> annotTypesBox = new JComboBox<String>();
  annotTypesBox.setMaximumRowCount(10);
  annotTypesBox.setModel(new DefaultComboBoxModel<String>(types.toArray(new String[types.size()])));
  DefaultCellEditor cellEditor = new DefaultCellEditor(annotTypesBox);
  cellEditor.setClickCountToStart(0);
  configureStackViewFrame.getTable().getColumnModel()
          .getColumn(ANNOTATION_TYPE).setCellEditor(cellEditor);
}