Java 8 JComboBox - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 JComboBox class.

This code example shows how to use the following methods:addItem
    add(scrollPane);
  } 
 
  public void setUpSportColumn(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);
  } 
 
  private static class MyTableModel extends AbstractTableModel {
6
CodeRank
This code example shows how to use the following methods:addActionListener, getSelectedIndex, removeActionListener, removeAllItems, setSelectedIndex
		this.kernel = app.getKernel();
		 
		model = new AnimationSpeedModel(app, this);
		 
			// combo box for  
		animationModeCB = new JComboBox();
		modeLabel = new JLabel();
		 
		// text field for animation step 
		speedLabel = new JLabel();
		tfAnimSpeed = new JTextField(5);
		speedLabel.setLabelFor(tfAnimSpeed);
		tfAnimSpeed.addActionListener(this);
		tfAnimSpeed.addFocusListener(this);
 
		// put it all together 
		JPanel animPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
		animPanel.add(speedLabel);
		animPanel.add(tfAnimSpeed);
		animPanel.add(modeLabel);

6
CodeRank
This code example shows how to use the following methods:addItemListener, getSelectedItem, setSelectedItem
    void showGUI(Properties fileProps) {
        Properties guiProps = new Properties(fileProps);
        JOptionPane p = createPane(guiProps);
        p.createDialog("Select Tool").setVisible(true);
 
        toolName = (String) toolChoice.getSelectedItem();
        toolArgs = argsField.getText();
 
        if (defaultCheck.isSelected()) {
            if (toolName.equals("")) {
                fileProps.remove("tool.name");
            } else { 
                fileProps.put("tool.name", toolName);
                fileProps.put(toolName + ".args", toolArgs);
            } 
            writeProperties(propertyFile, fileProps);
        } 
    } 
 
    JOptionPane createPane(final Properties props) {

6
CodeRank
This code example shows how to use the following methods:addActionListener, setModel, setRenderer
    mainPanel.add(parametersPanel, BorderLayout.PAGE_START);
     
    JLabel viewDefinitionsLabel = new JLabel("View Definitions");
    viewSelectionPanel.add(viewDefinitionsLabel);
     
    _comboBox = new JComboBox<ViewEntry>();
    _comboBox.setModel(getViewComboBoxModel());
    _comboBox.setRenderer(getViewListCellRenderer());
    viewSelectionPanel.add(_comboBox);
 
    final ConfigSource configSource = getToolContext().getConfigSource();
    final PositionSource positionSource = getToolContext().getPositionSource();
    final SecuritySource securitySource = getToolContext().getSecuritySource();
     
    _failuresTreeTable = new JXTreeTable(new DefaultTreeTableModel());
    _failuresTreeTable.setShowsRootHandles(true);
    _failuresTreeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
     
    JPanel panel = new JPanel();
    mainPanel.add(panel, BorderLayout.CENTER);

6
CodeRank
This code example shows how to use the following methods:setModel, setSelectedIndex
        lblPlayerNum = new javax.swing.JLabel();
        pnlPlayerName = new javax.swing.JPanel();
        txtPlayerName = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        cbLevel = new javax.swing.JComboBox();
 
        jLabel1.setLabelFor(cbPlayerType);
        jLabel1.setText("Type:");
 
        cbPlayerType.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cbPlayerType.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbPlayerTypeActionPerformed(evt);
            } 
        }); 
 
        lblPlayerNum.setFont(new java.awt.Font("Tahoma", 1, 11));
        lblPlayerNum.setText("Player Num:");
 

6
CodeRank
This code example shows how to use the following methods:addActionListener, setEditable
            log.debug("Exception getting interfaces.", e);
        } 
 
        JLabel label = new JLabel(JMeterUtils.getResString("protocol_java_classname")); // $NON-NLS-1$
 
        classnameCombo = new JComboBox(possibleClasses.toArray());
        classnameCombo.addActionListener(this);
        classnameCombo.setEditable(false);
        label.setLabelFor(classnameCombo);
 
        HorizontalPanel panel = new HorizontalPanel();
        panel.add(label);
        panel.add(classnameCombo);
 
        return panel;
    } 
 
    /** 
     * Handle action events for this component. This method currently handles 
     * events for the classname combo box. 
6
CodeRank
This code example shows how to use the following methods:addActionListener, setEditable
    private JPanel createClassPanel()
    { 
        JLabel label =
            new JLabel(JMeterUtils.getResString("protocol_java_classname")); //$NON-NLS-1$
 
        classnameCombo = new JComboBox();
        classnameCombo.addActionListener(this);
        classnameCombo.setEditable(false);
        label.setLabelFor(classnameCombo);
 
        methodName = new JComboBox();
        methodName.addActionListener(this);
        methodLabel.setLabelFor(methodName);
 
        setupClasslist(); 
 
        VerticalPanel panel = new VerticalPanel();
        panel.add(junit4);
        junit4.addItemListener(this);
        panel.add(filterpkg);

6
CodeRank
This code example shows how to use the following methods:getItemAt, getItemCount
        List<SelectionStrategy<? super Object>> strategies = new LinkedList<SelectionStrategy<? super Object>>();
        strategies.add(rank); 
        strategies.add(roulette); 
        SelectionStrategyControl<?> control = new SelectionStrategyControl<Object>(strategies);
        JComboBox component = control.getControl();
        assert component.getItemCount() == 2 : "Combobox should contain 2 entries, is " + component.getItemCount();
        assert component.getItemAt(0) == rank : "First item should be rank selection.";
        assert component.getItemAt(1) == roulette : "Second item should be roulette wheel selection.";
    } 
 
 
    @Test
    public void testChangeSelection() 
    { 
        SelectionStrategy<Object> quarter = new TruncationSelection(0.25); 
        SelectionStrategy<Object> half = new TruncationSelection(0.5); 
        List<SelectionStrategy<? super Object>> strategies = new LinkedList<SelectionStrategy<? super Object>>();
        strategies.add(quarter); 
        strategies.add(half); 
        SelectionStrategyControl<Object> control = new SelectionStrategyControl<Object>(strategies); 
6
CodeRank
This code example shows how to use the following methods:addActionListener, setEditable
            LOGGER.debug("Exception getting interfaces.", e);
        } 
 
        JLabel label = new JLabel(JMeterUtils.getResString("backend_listener_classname")); // $NON-NLS-1$
 
        classnameCombo = new JComboBox(possibleClasses.toArray());
        classnameCombo.addActionListener(this);
        classnameCombo.setEditable(false);
        label.setLabelFor(classnameCombo);
 
        HorizontalPanel classNamePanel = new HorizontalPanel();
        classNamePanel.add(label);
        classNamePanel.add(classnameCombo);
 
        queueSize = new JTextField("0", 5);  // TODO "0" is a hack to prevent NumberFormatException: For input string: ""
        queueSize.setName("Queue Size"); //$NON-NLS-1$
        JLabel queueSizeLabel = new JLabel(JMeterUtils.getResString("backend_listener_queue_size")); // $NON-NLS-1$
        queueSizeLabel.setLabelFor(queueSize);
        HorizontalPanel queueSizePanel = new HorizontalPanel();
        queueSizePanel.add(queueSizeLabel, BorderLayout.WEST);
6
CodeRank
This code example shows how to use the following methods:addPropertyChangeListener, addActionListener, getEditor, getSelectedItem, isEditable
    @Override 
    public void bindComponents() { 
        adjustComboBoxModel(); 
        adjustTextComponent(); 
        getValueDescriptor().addAttributeChangeListener(this);
        comboBox.addPropertyChangeListener("editable", this);
        comboBox.addActionListener(this);
    } 
 
    @Override 
    public void unbindComponents() { 
        comboBox.removeActionListener(this);
        comboBox.removePropertyChangeListener("editable", this);
        getValueDescriptor().removeAttributeChangeListener(this);
        unbindTextComponent(); 
    } 
 
    @Override 
    public void adjustComponents() { 
        Object value = getBinding().getPropertyValue(); 

6
CodeRank
See Code Examples for Java 8 JComboBox Methods: