Java 8 ItemEvent - 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 ItemEvent class.

This code example shows how to use the following methods:getItem, getStateChange
 
    private class ItemManager implements ItemListener {
 
	@Override 
	public void itemStateChanged(ItemEvent e) {
	    if (e.getStateChange() == ItemEvent.SELECTED) {
		Object val = e.getItem();
		if ("SOCKS".equals(val)) {
		    setEnabledComponent(host, true);
		    setEnabledComponent(port, true);
		    setEnabledComponent(vali, false);
		    setEnabledComponent(user, false);
		    setEnabledComponent(pass, false);
		} else if ("HTTP".equals(val)) {
		    setEnabledComponent(host, true);
		    setEnabledComponent(port, true);
		    setEnabledComponent(vali, false);
		    setEnabledComponent(user, true);
		    setEnabledComponent(pass, true);
		} else if ("HTTPS".equals(val)) {
5
CodeRank
This code example shows how to use the following methods:getItem, getStateChange, getSource
 
    private Object deselectedItem; 
    private boolean isUserAction = true;
 
    public void itemStateChanged(ItemEvent e) {
        int stateChange = e.getStateChange();
 
        switch (stateChange) {
            case ItemEvent.DESELECTED:
                deselectedItem = e.getItem();
                break; 
            case ItemEvent.SELECTED:
                // don't add event to undo list, if it was just the default setting 
                if (isUserAction) {
                    UndoManager undoManager = Application.getInstance().getUndoManager();
                    undoManager.addEdit(new JComboBoxUndoableEdit((JComboBox) e
                            .getSource(), deselectedItem, e.getItem(), this));
                     
                } 
                //set back to default value after the selecting new option 

5
CodeRank
This code example shows how to use the following methods:getItem, getStateChange
         * for this method performs the operations that need to occur when an item is selected 
         * (or deselected). 
         */ 
        public void itemStateChanged(ItemEvent e)
        { 
            if (e.getStateChange() == ItemEvent.SELECTED)
            { 
                propertySelected((IProperty)e.getItem());
            } 
        } 
    } 
 
    /** Listens to operation selections. */ 
    private class OperationSelectionListener implements ItemListener
    { 
        /** 
         * Invoked when an item has been selected or deselected by the user. The code written 
         * for this method performs the operations that need to occur when an item is selected 
         * (or deselected). 
         */ 
5
CodeRank
This code example shows how to use the following methods:getItem, getStateChange
		} 
	} 
 
	@Override 
	public void itemStateChanged(ItemEvent e) {
		if( e.getItem() == showInliers) {
			setShowInliers = e.getStateChange() != ItemEvent.DESELECTED;
		} else if( e.getItem() == showAll) {
			setShowAll = e.getStateChange() != ItemEvent.DESELECTED;
		} else if( e.getItem() == showView ) {
			setShowView = e.getStateChange() != ItemEvent.DESELECTED;
		} 
	} 
 
	public void setFPS( double fps ) {
		displayFPS.setText(String.format("%5.1f", fps));
	} 
 
	public void setKeyFrames(int totalFaults) {
		displayNumKeyFrames.setText(String.format("%5d", totalFaults));
5
CodeRank
This code example shows how to use the following methods:getStateChange, getSource
    /** 
     * Invoked when user selects some item from the list. 
     */ 
    public void itemStateChanged(ItemEvent e)
    { 
        if (e.getStateChange() == ItemEvent.DESELECTED) return;
 
        JComboBox box = (JComboBox)e.getSource();
        Object item = box.getSelectedItem();
 
        if (item instanceof Action) 
        { 
            ((Action)item).actionPerformed(null); 
            box.setSelectedIndex(0);
            editor.requestFocus();
        } 
    } 
} 
5
CodeRank
This code example shows how to use the following methods:
    public boolean pick(T v, boolean state) {
        boolean prior_state = this.picked.contains(v);
        if (state) {
            picked.add(v);
            if(prior_state == false) {
                fireItemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED,
                        v, ItemEvent.SELECTED));
            } 
 
        } else { 
            picked.remove(v);
            if(prior_state == true) {
                fireItemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED,
                    v, ItemEvent.DESELECTED));
            } 
 
        } 
        return prior_state;
    } 
 
5
CodeRank
This code example shows how to use the following methods:getStateChange
        } 
    } 
 
    public void itemStateChanged(ItemEvent event) {
        boolean selected =
            (event.getStateChange() == ItemEvent.SELECTED);
        images.setSortInverted(selected);
        if (selected) {
            setToolTipText(LOCALE.get("SortDownToolTip"));
            setIcon(UpIcon);
        } 
        else { 
            setToolTipText(LOCALE.get("SortUpToolTip"));
            setIcon(DownIcon);
        } 
        Prefs.putBoolean(InvertedKey, selected);
    } 
} 
5
CodeRank
This code example shows how to use the following methods:getStateChange
        setToolTipText(ToolTip);
        setEnabled(false); 
    } 
 
    public void itemStateChanged(ItemEvent event) {
        if (event.getStateChange() == ItemEvent.SELECTED) {
            doZoomToFit(); 
        } 
    } 
 
    // This zoom-to-fit logic is copied from Document.zoomToFit(). 
    void doZoomToFit() { 
        Rectangle rect = editor.getMaxImageBounds();
        // Sometimes during frame initialization, the max image bounds 
        // is reported as zero.  Perhaps some layout glitch involving 
        // scroll pane interaction? 
        if ((rect.width > 0) && (rect.height > 0)) {
            isChangingScale = true;
            Scale oldScale = scale.getCurrentScale();
            Scale newScale = engine.setScale(rect);
5
CodeRank
This code example shows how to use the following methods:getStateChange
        add(luminosityButton);
        add(rgbButton);
    } 
 
    public void itemStateChanged(ItemEvent event) {
        if (event.getStateChange() == ItemEvent.SELECTED) {
            setScale(); 
            if (! ZoneScaleButtons.this.undoSupport.isRestoring()) {
                undoSupport.postEdit(LOCALE.get("ZoneTypeEditName"));
            } 
        } 
    } 
 
    public void setBackground(Color color) { 
        super.setBackground(color); 
        if (rgbButton != null) {
            // After the base class constructor is done 
            rgbButton.setBackground(color);
            luminosityButton.setBackground(color);
        } 
5
CodeRank
This code example shows how to use the following methods:getStateChange
        // Concurrent resources download 
        concurrentDwn = new JCheckBox(JMeterUtils.getResString("web_testing_concurrent_download")); // $NON-NLS-1$
        concurrentDwn.addItemListener(new ItemListener() {
            @Override 
            public void itemStateChanged(final ItemEvent e) {
                if (imageParser.isSelected() && e.getStateChange() == ItemEvent.SELECTED) { concurrentPool.setEnabled(true); }
                else { concurrentPool.setEnabled(false); }
            } 
        }); 
        concurrentPool = new JTextField(2); // 2 columns size
        concurrentPool.setMinimumSize(new Dimension(10,20));
        concurrentPool.setMaximumSize(new Dimension(30,20));
        embeddedRsrcPanel.add(concurrentDwn);
        embeddedRsrcPanel.add(concurrentPool);
         
        // Embedded URL match regex 
        embeddedRE = new JLabeledTextField(JMeterUtils.getResString("web_testing_embedded_url_pattern"),20); // $NON-NLS-1$
        embeddedRsrcPanel.add(embeddedRE);
 
         
5
CodeRank
See Code Examples for Java 8 ItemEvent Methods: