类javax.swing.JComboBox源码实例Demo

下面列出了怎么用javax.swing.JComboBox的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: netbeans   文件: PerfUtil.java
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();
}
 
源代码2 项目: netbeans   文件: RendererPropertyDisplayer.java
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());
    }
}
 
源代码3 项目: swingsane   文件: CustomSettingsDialog.java
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);
}
 
源代码4 项目: openAGV   文件: DriverGUI.java
/**
 * 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));
}
 
源代码5 项目: Spark   文件: FlashingPreferenceDialog.java
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 );
}
 
源代码6 项目: cloudml   文件: MyEditingGraphMousePlugin.java
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 "";
}
 
源代码7 项目: pcgen   文件: PurchaseInfoTab.java
/**
 * 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();
}
 
源代码8 项目: LoboBrowser   文件: ItemListControl.java
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);
}
 
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());
}
 
源代码10 项目: WorldGrower   文件: GuiShowGovernanceAction.java
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();
		}
	});
}
 
源代码11 项目: Logisim   文件: Attributes.java
@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;
	}
}
 
源代码12 项目: btdex   文件: MarketEUR.java
@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);
}
 
源代码13 项目: jdk8u-jdk   文件: Test6505027.java
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));
}
 
源代码14 项目: DeconvolutionLab2   文件: LanguageModule.java
@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;
}
 
源代码15 项目: openjdk-jdk9   文件: JComboBoxOperator.java
/**
 * Maps {@code JComboBox.getItemCount()} through queue
 */
public int getItemCount() {
    return (runMapping(new MapIntegerAction("getItemCount") {
        @Override
        public int map() {
            return ((JComboBox) getSource()).getItemCount();
        }
    }));
}
 
源代码16 项目: astor   文件: StrokeChooserPanel.java
/**
 * 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();
        }
    });
}
 
源代码17 项目: GpsPrune   文件: InterpolateFilter.java
/** 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);
}
 
源代码18 项目: JRakNet   文件: BroadcastFrame.java
@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);
	}
}
 
源代码19 项目: constellation   文件: MappingPanel.java
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)));
}
 
源代码20 项目: marathonv5   文件: JComboBoxJavaElement.java
public static String getSelectedItemText(JComboBox combo) {
    int selectedIndex = combo.getSelectedIndex();
    if (selectedIndex == -1) {
        return "";
    }
    return JComboBoxOptionJavaElement.getText(combo, selectedIndex, true);
}
 
源代码21 项目: rcrs-server   文件: KernelStartupPanel.java
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;
}
 
源代码22 项目: mzmine2   文件: ParameterSetupDialog.java
/**
 * 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();
  }

}
 
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(), ""));
}
 
源代码24 项目: jeveassets   文件: JFixedToolBar.java
public void addComboBox(final JComboBox<?> jComboBox, int width) {
	if (width > 0) {
		setSize(jComboBox, width);
	}
	addSpace(10);
	super.add(jComboBox);
	addSpace(10);
}
 
源代码25 项目: marathonv5   文件: JavaElementFactory.java
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);
}
 
源代码26 项目: JDKSourceCode1.8   文件: MultiComboBoxUI.java
/**
 * 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;
}
 
源代码27 项目: netbeans   文件: TagsAndEditorsTest.java
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);
}
 
源代码28 项目: rapidminer-studio   文件: AnnotationCellEditor.java
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);
}
 
源代码29 项目: tn5250j   文件: SendEMailDialog.java
/**
 * 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());
	}
}
 
源代码30 项目: IBC   文件: AbstractLoginHandler.java
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");
            }
        }
    }
}
 
 类所在包
 同包方法