Java Code Examples for javax.swing.JComboBox

The following examples show how to use javax.swing.JComboBox. These examples are extracted from open source projects. 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 Project: netbeans   Source File: PerfUtil.java    License: Apache License 2.0 6 votes vote down vote up
public static void setSwingBrowser() {
    // Set Swing HTML Browser as default browser
    OptionsOperator optionsOper = OptionsOperator.invoke();
    optionsOper.selectGeneral();
    // "Web Browser:"
    String webBrowserLabel = Bundle.getStringTrimmed(
            "org.netbeans.modules.options.general.Bundle",
            "CTL_Web_Browser");
    JLabelOperator jloWebBrowser = new JLabelOperator(optionsOper, webBrowserLabel);
    // "Swing HTML Browser"
    String swingBrowserLabel = Bundle.getString(
            "org.netbeans.core.ui.Bundle",
            "Services/Browsers/SwingBrowser.ser");
    new JComboBoxOperator((JComboBox)jloWebBrowser.getLabelFor()).
            selectItem(swingBrowserLabel);
    optionsOper.ok();
}
 
Example 2
Source Project: netbeans   Source File: RendererPropertyDisplayer.java    License: Apache License 2.0 6 votes vote down vote up
protected void prepareRenderer(JComponent comp) {
    comp.setBackground(getBackground());
    comp.setForeground(getForeground());
    comp.setBounds(0, 0, getWidth(), getHeight());

    JComponent innermost;

    if ((innermost = findInnermostRenderer(comp)) instanceof JComboBox) {
        if (comp.getLayout() != null) {
            comp.getLayout().layoutContainer(comp);
        }
    }

    if (!isTableUI() && ((InplaceEditor) comp).supportsTextEntry()) {
        innermost.setBackground(PropUtils.getTextFieldBackground());
        innermost.setForeground(PropUtils.getTextFieldForeground());
    }
}
 
Example 3
Source Project: swingsane   Source File: CustomSettingsDialog.java    License: Apache License 2.0 6 votes vote down vote up
public CustomTableCellEditor(final JComboBox<?> comboBox, final OptionsOrderValuePair vp) {
  super(comboBox);
  comboBox.removeActionListener(delegate);
  valuePair = vp;
  delegate.setValue(comboBox);
  delegate = new EditorDelegate() {
    @Override
    public void setValue(Object val) {
      if (val instanceof JComboBox) {
        if (value == null) {
          value = val;
        }
      }
    }

    @Override
    public boolean stopCellEditing() {
      updateOption(valuePair, (Component) value);
      return true;
    }
  };
  comboBox.addActionListener(delegate);
  setClickCountToStart(1);
}
 
Example 4
Source Project: openAGV   Source File: DriverGUI.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * If a loopback adapter was chosen, this method initializes the combo boxes
 * with positions the user can set the vehicle to.
 *
 * @param rowIndex An index indicating which row this combo box belongs to
 * @param pointsCellEditor The <code>SingleCellEditor</code> containing
 * the combo boxes.
 */
private void initPointsComboBox(int rowIndex, SingleCellEditor pointsCellEditor) {
  final JComboBox<Point> pointComboBox = new JComboBox<>();

  objectService.fetchObjects(Point.class).stream()
      .sorted(Comparators.objectsByName())
      .forEach(point -> pointComboBox.addItem(point));
  pointComboBox.setSelectedIndex(-1);
  pointComboBox.setRenderer(new StringListCellRenderer<>(x -> x == null ? "" : x.getName()));

  pointComboBox.addItemListener((ItemEvent e) -> {
    Point newPoint = (Point) e.getItem();
    VehicleEntry vehicleEntry = vehicleEntryPool.getEntryFor(getSelectedVehicleName());
    if (vehicleEntry.getCommAdapter() instanceof SimVehicleCommAdapter) {
      SimVehicleCommAdapter adapter = (SimVehicleCommAdapter) vehicleEntry.getCommAdapter();
      adapter.initVehiclePosition(newPoint.getName());
    }
    else {
      LOG.debug("Vehicle {}: Not a simulation adapter -> not setting initial position.",
                vehicleEntry.getVehicle().getName());
    }
  });
  pointsCellEditor.setEditorAt(rowIndex, new DefaultCellEditor(pointComboBox));
}
 
Example 5
Source Project: Spark   Source File: FlashingPreferenceDialog.java    License: Apache License 2.0 6 votes vote down vote up
public FlashingPreferenceDialog() {
	JPanel flashingPanel = new JPanel();
	flashingEnabled = new JCheckBox();
	flashingType = new JComboBox();
	JLabel lTyps = new JLabel();
	flashingPanel.setLayout(new GridBagLayout());
	
	flashingEnabled.addActionListener( e -> updateUI(flashingEnabled.isSelected()) );
	
	flashingType.addItem(FlashingResources.getString("flashing.type.continuous"));
	flashingType.addItem(FlashingResources.getString("flashing.type.temporary"));
	
	
	flashingPanel.add(flashingEnabled, new GridBagConstraints(0, 0, 3, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
	flashingPanel.add(lTyps, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
	flashingPanel.add(flashingType, new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
	
	flashingPanel.setBorder(BorderFactory.createTitledBorder(FlashingResources.getString("title.flashing")));
	
	// Setup MNEMORICS
	ResourceUtils.resButton(flashingEnabled, FlashingResources.getString("flashing.enable"));
	ResourceUtils.resLabel(lTyps, flashingType, FlashingResources.getString("flashing.type"));
	
	setLayout(new VerticalFlowLayout());
	add( flashingPanel );
}
 
Example 6
public String selectClientPortInstance(RelationshipInstance bi) {
    JPanel panel = new JPanel();
    panel.add(new JLabel("Please make a selection:"));
    DefaultComboBoxModel model = new DefaultComboBoxModel();
    for (ComponentInstance ai : dm.getComponentInstances()) {
        if (ai instanceof InternalComponentInstance) {
            for (RequiredPortInstance ci : ((InternalComponentInstance) ai).getRequiredPorts()) {
                System.out.println(bi.getType().getRequiredEnd() + " #### " + ci.getType());
                if (ci.getType().equals(bi.getType().getRequiredEnd())) {
                    model.addElement(ci);
                }
            }
        }
    }
    JComboBox comboBox = new JComboBox(model);
    panel.add(comboBox);

    int result = JOptionPane.showConfirmDialog(null, panel, "RequiredPort", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
    switch (result) {
        case JOptionPane.OK_OPTION:
            bi.setRequiredEnd((RequiredPortInstance) comboBox.getSelectedItem());
            return ((RequiredPortInstance) comboBox.getSelectedItem()).getOwner().getName();
    }
    return "";
}
 
Example 7
Source Project: pcgen   Source File: PurchaseInfoTab.java    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Create a new instance of PurchaseInfoTab
 */
public PurchaseInfoTab()
{
	this.availableTable = new FilteredTreeViewTable<>();
	this.purchasedTable = new FilteredTreeViewTable<>();
	this.equipmentRenderer = new EquipmentRenderer();
	this.autoResizeBox = new JCheckBox();
	this.addCustomButton = new JButton();
	this.addEquipmentButton = new JButton();
	this.sellEquipmentButton = new JButton();
	this.removeEquipmentButton = new JButton();
	this.infoPane = new InfoPane();
	this.wealthLabel = new JFormattedTextField(NumberFormat.getNumberInstance());
	this.goldField = new JFormattedTextField(NumberFormat.getNumberInstance());
	this.goldModField = new JFormattedTextField(NumberFormat.getNumberInstance());
	this.buySellRateBox = new JComboBox<>();
	this.fundsAddButton = new JButton();
	this.fundsSubtractButton = new JButton();
	this.allowDebt = new JCheckBox();
	this.currencyLabels = new ArrayList<>();

	initComponents();
}
 
Example 8
Source Project: LoboBrowser   Source File: ItemListControl.java    License: MIT License 6 votes vote down vote up
public ItemListControl(final ItemEditorFactory<T> ief) {
  this.itemEditorFactory = ief;
  this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
  this.comboBox = new JComboBox<>();
  this.comboBox.setPreferredSize(new Dimension(100, 24));
  this.comboBox.setEditable(false);
  final JButton editButton = new JButton();
  editButton.setAction(new EditAction(false));
  editButton.setText("Edit");
  final JButton addButton = new JButton();
  addButton.setAction(new EditAction(true));
  addButton.setText("Add");
  final JButton removeButton = new JButton();
  removeButton.setAction(new RemoveAction());
  removeButton.setText("Remove");
  this.add(this.comboBox);
  this.add(editButton);
  this.add(addButton);
  this.add(removeButton);
}
 
Example 9
Source Project: netbeans   Source File: DatabaseExplorerInternalUIsTest.java    License: Apache License 2.0 6 votes vote down vote up
public void testComboboxWithDrivers() throws Exception {
    setUpDrivers();
    JComboBox combo = new JComboBox();
    DatabaseExplorerInternalUIs.connect(combo, JDBCDriverManager.getDefault());

    assertEquals(3, combo.getItemCount());
    JdbcUrl url = (JdbcUrl)combo.getItemAt(0);
    assertDriversEqual(driver2, url.getDriver());
    assertEquals(driver2.getClassName(), url.getClassName());
    assertEquals(driver2.getDisplayName(), url.getDisplayName());
    
    url = (JdbcUrl)combo.getItemAt(1);
    assertDriversEqual(driver1, url.getDriver());
    assertEquals(driver1.getClassName(), url.getClassName());
    assertEquals(driver1.getDisplayName(), url.getDisplayName());
}
 
Example 10
private void addActionHandlers(JButton okButton, WorldModel worldModel, JComboBox<Integer> shackComboBox, JComboBox<Integer> houseComboBox, JComboBox<Integer> sheriffComboBox, JComboBox<Integer> taxCollectorComboBox, JDialog dialog, boolean performerIsLeaderOfVillagers, JCheckBox ownerShackHouseCheckBox, JCheckBox maleCheckBox, JCheckBox femaleCheckBox, JCheckBox undeadCheckBox, JComboBox<Integer> candidateStageComboBox, JComboBox<Integer> votingStageComboBox) {
	okButton.addActionListener(new ActionListener() {

		@Override
		public void actionPerformed(ActionEvent event) {
			if (performerIsLeaderOfVillagers) {
				int shackTaxRate = (int) shackComboBox.getSelectedItem();
				int houseTaxRate = (int) houseComboBox.getSelectedItem();
				int sheriffWage = (int) sheriffComboBox.getSelectedItem();
				int taxCollectorWage = (int) taxCollectorComboBox.getSelectedItem();
				boolean onlyOwnerShackHouseCanVote = ownerShackHouseCheckBox.isSelected();
				boolean onlyMalesCanVote = maleCheckBox.isSelected();
				boolean onlyFemalesCanVote = femaleCheckBox.isSelected();
				boolean onlyUndeadCanVote = undeadCheckBox.isSelected();
				
				int candidateStageValue = (int) candidateStageComboBox.getSelectedItem();
				int votingStageValue = (int) votingStageComboBox.getSelectedItem();
				int endVotingInTurns = candidateStageValue + votingStageValue;
				
				int[] args = worldModel.getArgs(shackTaxRate, houseTaxRate, sheriffWage, taxCollectorWage, onlyOwnerShackHouseCanVote, onlyMalesCanVote, onlyFemalesCanVote, onlyUndeadCanVote, candidateStageValue, endVotingInTurns);
				Game.executeActionAndMoveIntelligentWorldObjects(playerCharacter, Actions.SET_GOVERNANCE_ACTION, args, world, dungeonMaster, playerCharacter, parent, imageInfoReader, soundIdReader);
			}
			dialog.dispose();
		}
	});
}
 
Example 11
Source Project: Logisim   Source File: Attributes.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public java.awt.Component getCellEditor(Integer value) {
	if (end - start + 1 > 32) {
		return super.getCellEditor(value);
	} else {
		if (options == null) {
			options = new Integer[end - start + 1];
			for (int i = start; i <= end; i++) {
				options[i - start] = Integer.valueOf(i);
			}
		}
		JComboBox<Object> combo = new JComboBox<Object>(options);
		if (value == null)
			combo.setSelectedIndex(-1);
		else
			combo.setSelectedItem(value);
		return combo;
	}
}
 
Example 12
Source Project: btdex   Source File: MarketEUR.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public JComponent getFieldEditor(String key, boolean editable, HashMap<String, String> fields) {
	if(key.equals(METHOD)) {
		JComboBox<String> combo = new JComboBox<String>();
		
		combo.addItem(SEPA);
		combo.addItem(SEPA_INSTANT);
		
		combo.setSelectedIndex(0);
		combo.setEnabled(editable);
		
		String value = fields.get(key);
		if(value.equals(SEPA_INSTANT))
			combo.setSelectedIndex(1);
		
		return combo;
	}
	return super.getFieldEditor(key, editable, fields);
}
 
Example 13
Source Project: jdk8u-jdk   Source File: Test6505027.java    License: 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 14
@Override
public JPanel buildExpandedPanel() {
	language = new HTMLPane("Monaco", 100, 100);
	cmb = new JComboBox<String>(new String[] { "Command line", "ImageJ Macro", "Java", "Matlab" });
	gui = new JComboBox<String>(new String[] { "Run (Headless)", "Launch (with control panel)" });
	txt = new JTextField("Job", 8);
	JPanel pn = new JPanel(new BorderLayout());
	pn.add(cmb, BorderLayout.WEST);
	pn.add(txt, BorderLayout.CENTER);
	pn.add(gui, BorderLayout.EAST);

	JPanel panel = new JPanel(new BorderLayout());
	panel.add(pn, BorderLayout.NORTH);
	panel.add(language.getPane(), BorderLayout.CENTER);
	cmb.addActionListener(this);
	gui.addActionListener(this);
	Config.register(getName(), "language", cmb, cmb.getItemAt(0));
	Config.register(getName(), "headless", gui, gui.getItemAt(0));
	Config.register(getName(), "job", txt, "Job");
	language.clear();
	return panel;
}
 
Example 15
/**
 * Maps {@code JComboBox.getItemCount()} through queue
 */
public int getItemCount() {
    return (runMapping(new MapIntegerAction("getItemCount") {
        @Override
        public int map() {
            return ((JComboBox) getSource()).getItemCount();
        }
    }));
}
 
Example 16
Source Project: astor   Source File: StrokeChooserPanel.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a panel containing a combo-box that allows the user to select
 * one stroke from a list of available strokes.
 *
 * @param current  the current stroke sample.
 * @param available  an array of 'available' stroke samples.
 */
public StrokeChooserPanel(StrokeSample current, StrokeSample[] available) {
    setLayout(new BorderLayout());
    this.selector = new JComboBox(available);
    this.selector.setSelectedItem(current);
    this.selector.setRenderer(new StrokeSample(new BasicStroke(1)));
    add(this.selector);
    // Changes due to focus problems!! DZ
    this.selector.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent evt) {
            getSelector().transferFocus();
        }
    });
}
 
Example 17
Source Project: GpsPrune   Source File: InterpolateFilter.java    License: GNU General Public License v2.0 5 votes vote down vote up
/** Make the panel contents */
protected void makePanelContents()
{
	setLayout(new BorderLayout());
	JPanel boxPanel = new JPanel();
	boxPanel.setLayout(new BoxLayout(boxPanel, BoxLayout.Y_AXIS));
	add(boxPanel, BorderLayout.NORTH);
	JLabel topLabel = new JLabel(I18nManager.getText("dialog.gpsbabel.filter.interpolate.intro"));
	topLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
	boxPanel.add(topLabel);
	boxPanel.add(Box.createVerticalStrut(18)); // spacer
	// Main three-column grid
	JPanel gridPanel = new JPanel();
	gridPanel.setLayout(new GridLayout(0, 3, 4, 4));
	gridPanel.add(new JLabel(I18nManager.getText("dialog.gpsbabel.filter.interpolate.distance")));
	_distField = new DecimalNumberField();
	_distField.addKeyListener(_paramChangeListener);
	gridPanel.add(_distField);
	_distUnitsCombo = new JComboBox<String>(new String[] {I18nManager.getText("units.kilometres"), I18nManager.getText("units.miles")});
	gridPanel.add(_distUnitsCombo);
	gridPanel.add(new JLabel(I18nManager.getText("dialog.gpsbabel.filter.interpolate.time")));
	_secondsField = new WholeNumberField(4);
	_secondsField.addKeyListener(_paramChangeListener);
	gridPanel.add(_secondsField);
	gridPanel.add(new JLabel(I18nManager.getText("units.seconds")));
	gridPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
	boxPanel.add(gridPanel);
}
 
Example 18
Source Project: JRakNet   Source File: BroadcastFrame.java    License: MIT License 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
	int index = ((JComboBox<?>) e.getSource()).getSelectedIndex();
	if (index == 0) {
		Discovery.setDiscoveryMode(DiscoveryMode.ALL_CONNECTIONS);
	} else if (index == 1) {
		Discovery.setDiscoveryMode(DiscoveryMode.OPEN_CONNECTIONS);
	} else {
		Discovery.setDiscoveryMode(DiscoveryMode.DISABLED);
	}
}
 
Example 19
Source Project: constellation   Source File: MappingPanel.java    License: Apache License 2.0 5 votes vote down vote up
private static void setColumn(final JTable table, final int columnIndex, final ArrayList<String> values0) {
    // Copy the list of labels into a String[] with a leading "" as the default "no choice" value.
    final String[] values = new String[values0.size() + 1];
    values[0] = "";
    for (int i = 0; i < values0.size(); i++) {
        values[i + 1] = values0.get(i);
    }

    final TableColumn tcol = table.getColumnModel().getColumn(columnIndex);
    tcol.setCellRenderer(new MappingCellRenderer(values));
    tcol.setCellEditor(new DefaultCellEditor(new JComboBox<>(values)));
}
 
Example 20
Source Project: marathonv5   Source File: JComboBoxJavaElement.java    License: Apache License 2.0 5 votes vote down vote up
public static String getSelectedItemText(JComboBox combo) {
    int selectedIndex = combo.getSelectedIndex();
    if (selectedIndex == -1) {
        return "";
    }
    return JComboBoxOptionJavaElement.getText(combo, selectedIndex, true);
}
 
Example 21
private <T> JComboBox createComboBox(List<T> options, T selected) {
    Object[] choices = options.toArray();
    JComboBox result = new JComboBox(choices);
    result.setSelectedItem(selected);
    result.setEnabled(choices.length > 1);
    return result;
}
 
Example 22
Source Project: mzmine2   Source File: ParameterSetupDialog.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Implementation for ActionListener interface
 */
@Override
public void actionPerformed(ActionEvent ae) {

  Object src = ae.getSource();

  if (src == btnOK) {
    closeDialog(ExitCode.OK);
  }

  if (src == btnCancel) {
    closeDialog(ExitCode.CANCEL);
  }

  if (src == btnHelp) {
    Platform.runLater(() -> {
      if (helpWindow != null) {
        helpWindow.show();
        helpWindow.toFront();
      } else {
        helpWindow = new HelpWindow(helpURL.toString());
        helpWindow.show();
      }
    });
  }

  if ((src instanceof JCheckBox) || (src instanceof JComboBox)) {
    parametersChanged();
  }

}
 
Example 23
private void fillCombo(JsonNode attrNode, DefaultComboBoxModel<NamedItem> comboModel, JComboBox combo) {
    JsonNode valArray = attrNode.path("values");
    comboModel.removeAllElements();
    for (JsonNode val : valArray) {
        comboModel.addElement(new NamedItem(val.get("id").asText(), val.get("name").asText()));
    }
    combo.setModel(comboModel);
    combo.setSelectedItem(new NamedItem(attrNode.path("default").asText(), ""));
}
 
Example 24
Source Project: jeveassets   Source File: JFixedToolBar.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void addComboBox(final JComboBox<?> jComboBox, int width) {
	if (width > 0) {
		setSize(jComboBox, width);
	}
	addSpace(10);
	super.add(jComboBox);
	addSpace(10);
}
 
Example 25
Source Project: marathonv5   Source File: JavaElementFactory.java    License: Apache License 2.0 5 votes vote down vote up
public static void reset() {
    add(Component.class, JavaElement.class);
    add(JList.class, JListJavaElement.class);
    add(JTabbedPane.class, JTabbedPaneJavaElement.class);
    add(JComboBox.class, JComboBoxJavaElement.class);
    add(JTable.class, JTableJavaElement.class);
    add(JTableHeader.class, JTableHeaderJavaElement.class);
    add(JTree.class, JTreeJavaElement.class);
    add(JToggleButton.class, JToggleButtonJavaElement.class);
    add(JSpinner.class, JSpinnerJavaElement.class);
    add(JProgressBar.class, JProgressBarJavaElement.class);
    add(JSplitPane.class, JSplitPaneJavaElement.class);
    add(JTextComponent.class, JTextComponentJavaElement.class);
    add(EditorContainer.class, JTreeEditingContainerJavaElement.class);
    add(JEditorPane.class, JEditorPaneJavaElement.class);
    add(JMenuItem.class, JMenuItemJavaElement.class);
    add(JSlider.class, JSliderJavaElement.class);
    add(JSpinner.class, JSpinnerJavaElement.class);
    add(DefaultEditor.class, DefaultEditorJavaElement.class);
    add(JColorChooser.class, JColorChooserJavaElement.class);
    add(JFileChooser.class, JFileChooserJavaElement.class);
    add("com.jidesoft.swing.TristateCheckBox", JideTristateCheckBoxElement.class);
    add("com.jidesoft.swing.CheckBoxListCellRenderer", JideCheckBoxListItemElement.class);
    add("com.jidesoft.swing.CheckBoxTreeCellRenderer", JideCheckBoxTreeNodeElement.class);
    add("com.jidesoft.spinner.DateSpinner", JideDateSpinnerElement.class);
    add("com.jidesoft.swing.JideSplitPane", JideSplitPaneElement.class);
}
 
Example 26
Source Project: JDKSourceCode1.8   Source File: MultiComboBoxUI.java    License: MIT License 5 votes vote down vote up
/**
 * Invokes the <code>isFocusTraversable</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public boolean isFocusTraversable(JComboBox a) {
    boolean returnValue =
        ((ComboBoxUI) (uis.elementAt(0))).isFocusTraversable(a);
    for (int i = 1; i < uis.size(); i++) {
        ((ComboBoxUI) (uis.elementAt(i))).isFocusTraversable(a);
    }
    return returnValue;
}
 
Example 27
Source Project: netbeans   Source File: TagsAndEditorsTest.java    License: Apache License 2.0 5 votes vote down vote up
public void testEditableSingleTagEditor() throws Exception {
    if (!canSafelyRunFocusTests()) {
        return;
    }
    Node n = new TNode(new EditableSingleTagEditor());
    setCurrentNode(n, ps);
    clickCell(ps.table, 1, 1);
    Component c = focusComp();
    assertTrue("Clicking on an editable property that returns a 1 element " +
            "array from getTags() should send focus to a combo box's child editor component",
            c.getParent() instanceof JComboBox);
}
 
Example 28
private static JComboBox<String> makeComboBox() {
	Vector<String> values = new Vector<String>();
	values.add(NONE);
	values.add(NAME);
	for (String a : Annotations.ALL_KEYS_ATTRIBUTE) {
		values.add(a);
	}
	return new JComboBox<>(values);
}
 
Example 29
Source Project: tn5250j   Source File: SendEMailDialog.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the combo box items to the string token from to.
 * The separator is a '|' character.
 *
 * @param to
 * @param boxen
 */
private void setToCombo(String to, JComboBox boxen) {

	StringTokenizer tokenizer = new StringTokenizer(to, "|");

	boxen.removeAllItems();

	while (tokenizer.hasMoreTokens()) {
		boxen.addItem(tokenizer.nextToken());
	}
}
 
Example 30
Source Project: IBC   Source File: AbstractLoginHandler.java    License: GNU General Public License v3.0 5 votes vote down vote up
protected final void setTradingMode(final Window window) {
    String tradingMode = TradingModeManager.tradingModeManager().getTradingMode();

    if (SwingUtils.findToggleButton(window, "Live Trading") != null && 
            SwingUtils.findToggleButton(window, "Paper Trading") != null) {
        // TWS 974 onwards uses toggle buttons rather than a combo box
        Utils.logToConsole("Setting Trading mode = " + tradingMode);
        if (tradingMode.equalsIgnoreCase(TradingModeManager.TRADING_MODE_LIVE)) {
            SwingUtils.findToggleButton(window, "Live Trading").doClick();
        } else {
            SwingUtils.findToggleButton(window, "Paper Trading").doClick();
        }
    } else {
        JComboBox<?> tradingModeCombo;
        if (Settings.settings().getBoolean("FIX", false)) {
            tradingModeCombo = SwingUtils.findComboBox(window, 1);
        } else {
            tradingModeCombo = SwingUtils.findComboBox(window, 0);
        }

        if (tradingModeCombo != null ) {
            Utils.logToConsole("Setting Trading mode = " + tradingMode);
            if (tradingMode.equalsIgnoreCase(TradingModeManager.TRADING_MODE_LIVE)) {
                tradingModeCombo.setSelectedItem("Live Trading");
            } else {
                tradingModeCombo.setSelectedItem("Paper Trading");
            }
        }
    }
}