Java Code Examples for java.awt.event.ItemEvent#getStateChange()

The following examples show how to use java.awt.event.ItemEvent#getStateChange() . 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: InteractiveIntegral.java    From SPIM_Registration with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void itemStateChanged( final ItemEvent arg0 )
{
	boolean oldState = lookForMaxima;
	
	if ( arg0.getStateChange() == ItemEvent.DESELECTED )				
		lookForMaxima = false;			
	else if ( arg0.getStateChange() == ItemEvent.SELECTED  )
		lookForMaxima = true;
	
	if ( lookForMaxima != oldState )
	{
		while ( isComputing )
			SimpleMultiThreading.threadWait( 10 );
		
		updatePreview( ValueChange.MINMAX );
	}
}
 
Example 2
Source File: CheckboxMenuItemGroup.java    From proxyee-down with Apache License 2.0 6 votes vote down vote up
@Override
public void itemStateChanged(ItemEvent e) {
  CheckboxMenuItem checkedItem = ((CheckboxMenuItem) e.getSource());
  if (e.getStateChange() == ItemEvent.SELECTED) {
    String selectedItemName = checkedItem.getName();
    for (CheckboxMenuItem item : items) {
      if (!item.getName().equals(selectedItemName)) {
        item.setState(false);
      }
    }
    if (itemListener != null) {
      itemListener.itemStateChanged(e);
    }
  } else {
    checkedItem.setState(true);
  }
}
 
Example 3
Source File: ReportingControlPanel.java    From VanetSim with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Invoked when an item changes. Used for the JCheckBoxes.
 * 
 * @param e the change event
 * 
 * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
 */
public void itemStateChanged(ItemEvent e){
	boolean state;
	if(e.getStateChange() == ItemEvent.SELECTED) state = true;
	else state = false;
	if(e.getSource() == monitoredBeaconZoneEditCheckBox_){
		monitoredBeaconZoneEdit_ = state;
	} else if(e.getSource() == doMonitorBeaconsCheckBox_){
		Vehicle.setBeaconMonitorZoneEnabled(state);
		updateBeaconInfo_ = state;
	} else if(e.getSource() == monitoredBeaconZoneShowCheckBox_){
		Renderer.getInstance().setShowBeaconMonitorZone(state);
		Renderer.getInstance().ReRender(false, false);
	} else if(e.getSource() == autoUpdateStatisticsCheckBox_){
		updateStatistics_ = state;
	}
}
 
Example 4
Source File: CameraTab.java    From FoxTelem with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void itemStateChanged(ItemEvent e) {
	Object source = e.getItemSelectable();
	
	if (source == showLatestImage) { //updateProperty(e, decoder.flipReceivedBits); }

		if (e.getStateChange() == ItemEvent.DESELECTED) {
			Config.showLatestImage = false;
		} else {
			Config.showLatestImage = true;
		}
		Config.save();
		
	}

	
}
 
Example 5
Source File: HerciHSTab.java    From FoxTelem with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void itemStateChanged(ItemEvent e) {
	super.itemStateChanged(e);
	Object source = e.getItemSelectable();

	if (source == showRawValues) { //updateProperty(e, decoder.flipReceivedBits); }
		if (e.getStateChange() == ItemEvent.DESELECTED) {
			Config.displayRawValues = false;
		} else {
			Config.displayRawValues = true;
		}
		Config.save();
		if (hsHeader != null) {
			updateTab(hsHeader, false);
		}
		
	}

}
 
Example 6
Source File: ExtraPanel.java    From megamek with GNU General Public License v2.0 6 votes vote down vote up
public void itemStateChanged(ItemEvent ev) {
    ClientGUI clientgui = unitDisplay.getClientGUI();
    if (clientgui == null) {
        return;
    }
    // Only act when a new item is selected
    if (ev.getStateChange() != ItemEvent.SELECTED) {
        return;
    }
    if ((ev.getItemSelectable() == chSensors)) {
        int sensorIdx = chSensors.getSelectedIndex();
        Entity en = clientgui.getClient().getGame().getEntity(myMechId);
        Sensor s = en.getSensors().elementAt(sensorIdx);
        en.setNextSensor(s);
        refreshSensorChoices(en);
        String sensorMsg = Messages.getString(
                "MechDisplay.willSwitchAtEnd", new Object[] { //$NON-NLS-1$
                        "Active Sensors", s.getDisplayName() }); //$NON-NLS-1$
        clientgui.systemMessage(sensorMsg);
        clientgui.getClient().sendSensorChange(myMechId, sensorIdx);
    }
}
 
Example 7
Source File: LWChoicePeer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void itemStateChanged(final ItemEvent e) {
    // AWT Choice sends SELECTED event only whereas JComboBox
    // sends both SELECTED and DESELECTED.
    if (e.getStateChange() == ItemEvent.SELECTED) {
        synchronized (getDelegateLock()) {
            if (skipPostMessage) {
                return;
            }
            getTarget().select(getDelegate().getSelectedIndex());
        }
        postEvent(new ItemEvent(getTarget(), ItemEvent.ITEM_STATE_CHANGED,
                                e.getItem(), ItemEvent.SELECTED));
    }
}
 
Example 8
Source File: ThemesPanel.java    From magarena with GNU General Public License v3.0 5 votes vote down vote up
private void doThemeItemStateChanged(ItemEvent e) {
    if (e.getStateChange() == ItemEvent.SELECTED) {
        SwingUtilities.invokeLater(() -> {
            setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            if (getSelectedThemeName().equals(selectedTheme.getName())) {
                setTheme(selectedTheme);
            } else {
                setTheme(ThemeFactory.getInstance().loadTheme(getSelectedThemeName()));
            }
            setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
        });
    }
}
 
Example 9
Source File: BasicCompanionView.java    From libreveris with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void itemStateChanged (ItemEvent evt)
{
    // The need checkbox has changed
    if (evt.getStateChange() == ItemEvent.SELECTED) {
        companion.setNeed(Need.SELECTED);
    } else {
        companion.setNeed(Need.NOT_SELECTED);
    }

    update();
}
 
Example 10
Source File: AbstractSampleLAICPMSRawDataManagerDialog.java    From ET_Redux with Apache License 2.0 5 votes vote down vote up
@Override
public void itemStateChanged ( ItemEvent evt ) {

    if ( evt.getStateChange() == ItemEvent.SELECTED ) {
        // Item was just selected
        mySample.setMineralName( (String) evt.getItem() );

    } else if ( evt.getStateChange() == ItemEvent.DESELECTED ) {
        // Item is no longer selected
    }
}
 
Example 11
Source File: LWChoicePeer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void itemStateChanged(final ItemEvent e) {
    // AWT Choice sends SELECTED event only whereas JComboBox
    // sends both SELECTED and DESELECTED.
    if (e.getStateChange() == ItemEvent.SELECTED) {
        synchronized (getDelegateLock()) {
            if (skipPostMessage) {
                return;
            }
            getTarget().select(getDelegate().getSelectedIndex());
        }
        postEvent(new ItemEvent(getTarget(), ItemEvent.ITEM_STATE_CHANGED,
                                e.getItem(), ItemEvent.SELECTED));
    }
}
 
Example 12
Source File: StateChangeAction.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void itemStateChanged(ItemEvent evt)
{
    if(evt.getStateChange() == 1)
        setSelected(true);
    else
        setSelected(false);
    if(listener != null)
        listener.itemStateChanged(evt);
}
 
Example 13
Source File: AbstractSampleFromProjectManagerDialog.java    From ET_Redux with Apache License 2.0 5 votes vote down vote up
@Override
public void itemStateChanged(ItemEvent evt) {

    if (evt.getStateChange() == ItemEvent.SELECTED) {
        // Item was just selected
        mySample.setAnalysisPurpose(ANALYSIS_PURPOSE.valueOf((String) evt.getItem()));

    } else if (evt.getStateChange() == ItemEvent.DESELECTED) {
        // Item is no longer selected
    }
}
 
Example 14
Source File: PCGenMenuBar.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void itemStateChanged(ItemEvent e)
{
	TempBonusFacade bonus = (TempBonusFacade) e.getItemSelectable().getSelectedObjects()[0];
	if (e.getStateChange() == ItemEvent.SELECTED)
	{
		character.addTempBonus(bonus);
	}
	else
	{
		character.removeTempBonus(bonus);
	}
}
 
Example 15
Source File: ClassLevelTableModel.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void itemStateChanged(ItemEvent e)
{
	if (e.getStateChange() == ItemEvent.SELECTED)
	{
		fireTableRowsUpdated(levels.getSize(), levels.getSize());
	}
}
 
Example 16
Source File: AllSelectionBindingItemListener.java    From kieker with Apache License 2.0 5 votes vote down vote up
@Override
public void itemStateChanged(final ItemEvent event) {
	final boolean selected = (ItemEvent.SELECTED == event.getStateChange());
	for (final JCheckBox bindedCheckBox : this.bindedCheckBoxes) {
		bindedCheckBox.setSelected(selected);
	}
}
 
Example 17
Source File: PCGenMenuBar.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void itemStateChanged(ItemEvent e)
{
	if (e.getStateChange() == ItemEvent.SELECTED)
	{
		Object item = e.getItemSelectable().getSelectedObjects()[0];
		Level level = ((LoggingLevelWrapper) item).getLevel();
		Logging.setCurrentLoggingLevel(level);
	}
}
 
Example 18
Source File: CustomizerSources.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public void itemStateChanged(ItemEvent e) {
    if (e.getStateChange() == ItemEvent.SELECTED) {
        validateFields();
    }
}
 
Example 19
Source File: ServiceDialog.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public void itemStateChanged(ItemEvent e) {
    if (e.getStateChange() == ItemEvent.SELECTED) {
        int index = cbName.getSelectedIndex();

        if ((index >= 0) && (index < services.length)) {
            if (!services[index].equals(psCurrent)) {
                psCurrent = services[index];
                uiFactory = psCurrent.getServiceUIFactory();
                changedService = true;

                Destination dest =
                    (Destination)asOriginal.get(Destination.class);
                // to preserve the state of Print To File
                if ((dest != null || isPrintToFileSelected())
                    && psCurrent.isAttributeCategorySupported(
                                                Destination.class)) {

                    if (dest != null) {
                        asCurrent.add(dest);
                    } else {
                        dest = (Destination)psCurrent.
                            getDefaultAttributeValue(Destination.class);
                        // "dest" should not be null. The following code
                        // is only added to safeguard against a possible
                        // buggy implementation of a PrintService having a
                        // null default Destination.
                        if (dest == null) {
                            try {
                                dest =
                                    new Destination(new URI("file:out.prn"));
                            } catch (URISyntaxException ue) {
                            }
                        }

                        if (dest != null) {
                            asCurrent.add(dest);
                        }
                    }
                } else {
                    asCurrent.remove(Destination.class);
                }
            }
        }
    }
}
 
Example 20
Source File: RemoteProductsRepositoryPanel.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
public RemoteProductsRepositoryPanel(RemoteProductsRepositoryProvider productsRepositoryProvider, ComponentDimension componentDimension,
                                     MissionParameterListener missionParameterListener, WorldMapPanelWrapper worlWindPanel) {

    super(worlWindPanel, componentDimension, new BorderLayout(0, componentDimension.getGapBetweenRows()));

    if (productsRepositoryProvider == null) {
        throw new NullPointerException("The remote products repository provider is null.");
    }

    this.productsRepositoryProvider = productsRepositoryProvider;
    this.missionParameterListener = missionParameterListener;

    if (this.productsRepositoryProvider.requiresAuthentication()) {
        ItemRenderer<Credentials> accountsItemRenderer = new ItemRenderer<Credentials>() {
            @Override
            public String getItemDisplayText(Credentials item) {
                return (item == null) ? " " : item.getUserPrincipal().getName();
            }
        };
        this.userAccountsComboBox = new CustomComboBox(accountsItemRenderer, componentDimension.getTextFieldPreferredHeight(), false, componentDimension.getTextFieldBackgroundColor());
    } else {
        this.userAccountsComboBox = null;
    }

    String[] availableMissions = this.productsRepositoryProvider.getAvailableMissions();
    if (availableMissions.length > 0) {
        String valueToSelect = availableMissions[0];
        this.missionsComboBox = SwingUtils.buildComboBox(availableMissions, valueToSelect, this.componentDimension.getTextFieldPreferredHeight(), false);
        this.missionsComboBox.setBackground(this.componentDimension.getTextFieldBackgroundColor());
        this.missionItemListener = new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent itemEvent) {
                if (itemEvent.getStateChange() == ItemEvent.SELECTED) {
                    newSelectedMission();
                }
            }
        };
        this.missionsComboBox.addItemListener(this.missionItemListener);
    } else {
        throw new IllegalStateException("At least one supported mission must be defined for '"+ getRepositoryName()+"' remote repository.");
    }

    this.parameterComponents = Collections.emptyList();
}