javax.swing.JComboBox Java Examples

The following examples show how to use javax.swing.JComboBox. 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: ItemListControl.java    From LoboBrowser with 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 #2
Source File: RendererPropertyDisplayer.java    From netbeans with 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 File: CustomSettingsDialog.java    From swingsane with 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 File: DriverGUI.java    From openAGV with 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 File: Attributes.java    From Logisim with 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 #6
Source File: FlashingPreferenceDialog.java    From Spark with 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 #7
Source File: PerfUtil.java    From netbeans with 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 #8
Source File: GuiShowGovernanceAction.java    From WorldGrower with GNU General Public License v3.0 6 votes vote down vote up
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 #9
Source File: DatabaseExplorerInternalUIsTest.java    From netbeans with 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
Source File: MarketEUR.java    From btdex with 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 #11
Source File: PurchaseInfoTab.java    From pcgen with 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 #12
Source File: MyEditingGraphMousePlugin.java    From cloudml with GNU Lesser General Public License v3.0 6 votes vote down vote up
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 #13
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 #14
Source File: LanguageModule.java    From DeconvolutionLab2 with GNU General Public License v3.0 6 votes vote down vote up
@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
Source File: MultiGradientTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private JComboBox createCombo(JPanel panel, Enum e) {
    JComboBox cmb = new JComboBox();
    cmb.setModel(new EnumComboBoxModel(e.getClass()));
    cmb.addActionListener(this);
    panel.add(cmb);
    return cmb;
}
 
Example #16
Source File: AddClassMapping.java    From AML-Project with Apache License 2.0 5 votes vote down vote up
private void buildTargetResultsPanel()
{
       //Results panel: contains the list of all classes that match que query
       tResults = new JPanel();
       tResults.setLayout(new BoxLayout(tResults, BoxLayout.PAGE_AXIS));
       //Create a label
       JLabel tLabel = new JLabel("Select a target class from the list of search results or go back to the full class list:");
       JPanel tLPanel = new JPanel();
       tLPanel.add(tLabel);
       tResults.add(tLPanel);
       Vector<String> sNames = new Vector<String>(targetRes.size());
       for(int i : targetRes)
       	sNames.add(target.getBestName(i));
       //Create the search area and button
	targetResult = new JTextArea(1,37);
	targetResult.setText(targetSearch.getText());
	targetResult.setEditable(false);
	targetResult.setBackground(Color.LIGHT_GRAY);
	backT = new JButton("Back");
	backT.setPreferredSize(new Dimension(70,28));
	backT.addActionListener(this);
	//Put them in a subpanel, side by side
	JPanel tSearchPanel = new JPanel();
	tSearchPanel.add(targetResult);
       tSearchPanel.add(backT);
       tResults.add(tSearchPanel);
       //Build the combo box with all the primary class names from the results
       targetResults = new JComboBox<String>(sNames);
       targetResults.setPreferredSize(new Dimension(500,28));
       //Put it in a subpanel so that it doesn't resize automatically
       JPanel tClassPanel = new JPanel();
       tClassPanel.add(targetResults);
       tResults.add(tClassPanel);
}
 
Example #17
Source File: RunAsPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void addNotify() {
    super.addNotify();
    if (!comboBoxModel.isInitialized) {
        Collection<InsidePanel> insidePanels = allInsidePanels.values();
        initComboModel(insidePanels);
        for (InsidePanel insidePanel : insidePanels) {
            final JComboBox<String> comboBox = insidePanel.getRunAsCombo();
            comboBox.setModel(comboBoxModel);
        }
        comboBoxModel.setAsInitialized();
    }
}
 
Example #18
Source File: TestDataComponent.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 5 votes vote down vote up
private void searchTestData(Object source) {
    JTabbedPane tab = (JTabbedPane) source;
    List<String> tabs = new ArrayList<>();
    for (int i = 0; i < tab.getTabCount() - 1; i++) {
        tabs.add(tab.getTitleAt(i));
    }
    JComboBox combo = new JComboBox(tabs.toArray());
    int option = JOptionPane.showConfirmDialog(null, combo,
            "Go To TestData",
            JOptionPane.DEFAULT_OPTION);
    if (option == JOptionPane.OK_OPTION) {
        tab.setSelectedIndex(tabs.indexOf(combo.getSelectedItem().toString()));
    }
}
 
Example #19
Source File: bug6632953.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String... args) throws Exception {
    MetalComboBoxUI ui = new MetalComboBoxUI();
    ui.installUI(new JComboBox());
    ui.getBaseline(new JComboBox(), 0, 0);
    ui.getBaseline(new JComboBox(), 1, 1);
    ui.getBaseline(new JComboBox(), 2, 2);
    ui.getBaseline(new JComboBox(), 3, 3);
    ui.getBaseline(new JComboBox(), 4, 4);
}
 
Example #20
Source File: ColorComboBox.java    From netbeans with Apache License 2.0 5 votes vote down vote up
static Color getColor (JComboBox<ColorValue> combo) {
    // The last item is Inherited Color or None
    if (combo.getSelectedIndex() < combo.getItemCount() - 1) {
        return ((ColorValue) combo.getSelectedItem()).color;
    } else {
        return null;
    }
}
 
Example #21
Source File: StrokeChooserPanel.java    From astor with 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 #22
Source File: SerialDateChooserPanel.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Constructs a panel containing two JComboBoxes (for the month and year) and a button
 * (to reset the date to TODAY).
 *
 * @return the panel.
 */
private JPanel constructSelectionPanel() {
    final JPanel p = new JPanel();
    this.monthSelector = new JComboBox(SerialDate.getMonths());
    this.monthSelector.addActionListener(this);
    this.monthSelector.setActionCommand("monthSelectionChanged");
    p.add(this.monthSelector);

    this.yearSelector = new JComboBox(getYears(0));
    this.yearSelector.addActionListener(this);
    this.yearSelector.setActionCommand("yearSelectionChanged");
    p.add(this.yearSelector);

    return p;
}
 
Example #23
Source File: AttributeBonusEditor.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent event) {
    String command = event.getActionCommand();
    if (CHANGE_ATTRIBUTE.equals(command)) {
        ((AttributeBonus) getFeature()).setAttribute(BonusAttributeType.values()[((JComboBox<?>) event.getSource()).getSelectedIndex()]);
        Commitable.sendCommitToFocusOwner();
        rebuild();
    } else if (CHANGE_LIMITATION.equals(command)) {
        ((AttributeBonus) getFeature()).setLimitation((AttributeBonusLimitation) ((JComboBox<?>) event.getSource()).getSelectedItem());
    } else {
        super.actionPerformed(event);
    }
}
 
Example #24
Source File: TableCellEditorFactory.java    From ramus with GNU General Public License v3.0 5 votes vote down vote up
private TableCellEditor createFontEditor() {
    JComboBox box = new JComboBox();
    box.addItem(null);
    for (String name : GraphicsEnvironment.getLocalGraphicsEnvironment()
            .getAvailableFontFamilyNames())
        box.addItem(name);
    return new DefaultCellEditor(box);
}
 
Example #25
Source File: ConnectionFailedTask.java    From JPPF with Apache License 2.0 5 votes vote down vote up
/**
 * Perform the task.
 */
@Override
public void run() {
  synchronized(statsHandler) {
    if (statsHandler.dataHolderMap.get(driver.getUuid()) != null) {
      final ConnectionDataHolder cdh = statsHandler.dataHolderMap.remove(driver.getUuid());
      if (cdh != null) cdh.close();
    }
  }
  JComboBox<?> box = null;
  while (statsHandler.getClientHandler().getServerListOption() == null) goToSleep(50L);
  final JPPFClientConnection c = driver.getConnection();
  synchronized(statsHandler) {
    if (debugEnabled) log.debug("removing client connection " + c.getName() + " from driver combo box");
    box = ((ComboBoxOption) statsHandler.getClientHandler().getServerListOption()).getComboBox();
    final int count = box.getItemCount();
    int idx = -1;
    for (int i=0; i<count; i++) {
      final Object o = box.getItemAt(i);
      if (c.equals(o)) {
        box.removeItemAt(i);
        idx = i;
        break;
      }
    }
    if ((idx >= 0) && (box.getItemCount() > 0)) {
      if ((statsHandler.getClientHandler().currentDriver == null) || c.equals(statsHandler.getClientHandler().currentDriver.getConnection())) {
        final int n = Math.min(idx, box.getItemCount()-1);
        final TopologyDriver item = (TopologyDriver) box.getItemAt(n);
        statsHandler.getClientHandler().currentDriver = item;
        box.setSelectedItem(item);
      }
    }
  }
}
 
Example #26
Source File: MultiGradientTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private JComboBox createCombo(JPanel panel, Enum e) {
    JComboBox cmb = new JComboBox();
    cmb.setModel(new EnumComboBoxModel(e.getClass()));
    cmb.addActionListener(this);
    panel.add(cmb);
    return cmb;
}
 
Example #27
Source File: OutlierVisualTab.java    From moa with GNU General Public License v3.0 5 votes vote down vote up
private void comboXActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboXActionPerformed
    if (visualizer == null) return;
    JComboBox cb = (JComboBox)evt.getSource();
    int dim = cb.getSelectedIndex();
    streamPanel0.setActiveXDim(dim);
    streamPanel1.setActiveXDim(dim);
    if(visualizer!=null)
        visualizer.redraw();
}
 
Example #28
Source File: AbstractLoginHandler.java    From IBC with 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");
            }
        }
    }
}
 
Example #29
Source File: SendEMailDialog.java    From tn5250j with 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 File: AnnotationCellEditor.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
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);
}