Example usage for java.awt.event ItemEvent getSource

List of usage examples for java.awt.event ItemEvent getSource

Introduction

In this page you can find the example usage for java.awt.event ItemEvent getSource.

Prototype

public Object getSource() 

Source Link

Document

The object on which the Event initially occurred.

Usage

From source file:ExText.java

public void itemStateChanged(ItemEvent event) {
    Object src = event.getSource();

    for (int i = 0; i < checks.length; i++) {
        if (src == checks[i]) {
            // Update the checkboxes
            checks[current].setState(false);
            current = i;//from   w  w  w  .  j  a  va2s.  c o  m
            checks[current].setState(true);

            if (listener != null)
                listener.checkboxChanged(this, i);
            return;
        }
    }
}

From source file:ExTransform.java

public void itemStateChanged(ItemEvent event) {
    Object src = event.getSource();

    // Check if it is switch choice
    for (int i = 0; i < switchMenu.length; i++) {
        if (src == switchMenu[i]) {
            // Update the checkboxes
            switchMenu[currentSwitch].setState(false);
            currentSwitch = i;/*from   ww w .j  a v  a 2s. c o m*/
            switchMenu[currentSwitch].setState(true);

            // Set the switch
            switchGroup.setWhichChild(options[currentSwitch].child);
            switchGroup.setChildMask(options[currentSwitch].mask);
            return;
        }
    }

    // Handle all other checkboxes
    super.itemStateChanged(event);
}

From source file:de.tor.tribes.ui.views.DSWorkbenchFarmManager.java

private void fireSelectionByCenterChangedEvent(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_fireSelectionByCenterChangedEvent
    coordSpinner.setEnabled(evt.getSource() == jByCenter);
}

From source file:ExLightScope.java

public void itemStateChanged(ItemEvent event) {
    Object src = event.getSource();
    if (src == light1OnOffMenu) {
        light1OnOff = light1OnOffMenu.getState();
        light1.setEnable(light1OnOff);//from  w w  w .  ja v  a  2 s  . c  om
        return;
    }
    if (src == light2OnOffMenu) {
        light2OnOff = light2OnOffMenu.getState();
        light2.setEnable(light2OnOff);
        return;
    }
    if (src == light3OnOffMenu) {
        light3OnOff = light3OnOffMenu.getState();
        light3.setEnable(light3OnOff);
        return;
    }

    // Handle all other checkboxes
    super.itemStateChanged(event);
}

From source file:de.dmarcini.submatix.pclogger.gui.MainCommGUI.java

/**
 * Checkbox hat sich verndert/*from   www  .ja va2s. com*/
 */
@Override
public void itemStateChanged(ItemEvent ev) {
    if (ignoreAction)
        return;
    // ////////////////////////////////////////////////////////////////////////
    // Checkbox Event?
    if (ev.getSource() instanceof JCheckBox) {
        JCheckBox cb = (JCheckBox) ev.getItemSelectable();
        String cmd = cb.getActionCommand();
        // //////////////////////////////////////////////////////////////////////
        // Dynamische Gradienten?
        if (cmd.equals("dyn_gradients_on")) {
            lg.debug("dynamic gradients <" + cb.isSelected() + ">");
            currentConfig.setDynGradientsEnable(cb.isSelected());
        }
        // //////////////////////////////////////////////////////////////////////
        // Deepstops
        else if (cmd.equals("deepstops_on")) {
            lg.debug("depstops <" + cb.isSelected() + ">");
            currentConfig.setDeepStopEnable(cb.isSelected());
        }
        // //////////////////////////////////////////////////////////////////////
        // Passive Semiclose Rebreather Mode?
        else if (cmd.equals("individuals_pscr_on")) {
            lg.debug("pscr mode  <" + cb.isSelected() + ">");
            currentConfig.setPscrModeEnabled(cb.isSelected());
        }
        // //////////////////////////////////////////////////////////////////////
        // Sensor warning on/off
        else if (cmd.equals("individual_sensors_on")) {
            lg.debug("sensors on  <" + cb.isSelected() + ">");
            currentConfig.setSensorsEnabled(cb.isSelected());
        }
        // //////////////////////////////////////////////////////////////////////
        // Warnungen an/aus
        else if (cmd.equals("individuals_warnings_on")) {
            lg.debug("warnings on  <" + cb.isSelected() + ">");
            currentConfig.setSountEnabled(cb.isSelected());
        } else {
            lg.warn("unknown item changed: <" + cb.getActionCommand() + "> <" + cb.isSelected() + ">");
        }
    }
}

From source file:ExDepthCue.java

public void itemStateChanged(ItemEvent event) {
    Object src = event.getSource();

    // Check if depth-cueing is enabled
    if (src == depthCueOnOffMenu) {
        depthCueOnOff = depthCueOnOffMenu.getState();
        if (depthCueOnOff) {
            // If on, enable color menu and fog
            colorMenu.setEnabled(true);// w  ww  . ja  va 2s . com
            fogSwitch.setWhichChild(0); // on
        } else {
            // If off, disable color menu and fog
            colorMenu.setEnabled(false);
            fogSwitch.setWhichChild(Switch.CHILD_NONE); // off
        }
    }

    // Handle all other checkboxes
    super.itemStateChanged(event);
}

From source file:ExLightBounds.java

public void itemStateChanged(ItemEvent event) {
    Object src = event.getSource();
    if (src == boundingLeafOnOffMenu) {
        boundingLeafOnOff = boundingLeafOnOffMenu.getState();
        if (boundingLeafOnOff) {
            // Use the bounding leaf
            light.setInfluencingBoundingLeaf(leafBounds);

            // A bounding leaf overrides bounds,
            // but for neatness we can turn them off
            // (doesn't work in Alpha release of Java3D)
            light.setInfluencingBounds(null);
            positionMenu.setEnabled(true);
        } else {// www .  j a v a  2 s  . c o  m
            // Use bounds on the light itself
            Bounds bou = (Bounds) bounds[currentBounds].value;
            light.setInfluencingBoundingLeaf(null);
            light.setInfluencingBounds(bou);
            positionMenu.setEnabled(false);
        }
        return;
    }

    // Handle all other checkboxes
    super.itemStateChanged(event);
}

From source file:ExTexture.java

public void itemStateChanged(ItemEvent event) {
    Object src = event.getSource();

    // Check if it is the texture on/off choice
    if (src == textureOnOffMenu) {
        textureOnOff = textureOnOffMenu.getState();
        Texture tex = textureComponents[currentImage];
        tex.setEnable(textureOnOff);/*w  w  w.  ja v  a  2 s  .  c o m*/
    }

    // Handle all other checkboxes
    super.itemStateChanged(event);
}

From source file:edu.purdue.cc.bionet.ui.CorrelationDisplayPanel.java

/**
 * The itemStateChanged method of the ItemListener interface.
 * @see ItemListener#itemStateChanged(ItemEvent)
 * //from ww  w.j  a  va2  s. c  o m
 * @param e The event which triggered this action.
 */
public void itemStateChanged(ItemEvent e) {
    if (e.getStateChange() == ItemEvent.SELECTED) {
        Object item = e.getSource();
        if (item == this.highContrastColorMenuItem) {
            graph.setBackground(Color.BLACK);
            graph.setForeground(Color.WHITE);
            graph.setPickedLabelColor(Color.WHITE);
            graph.setVertexPaint(Color.ORANGE.darker());
            graph.setPickedVertexPaint(Color.RED);
            graph.setPickedEdgePaint(Color.WHITE);
            heatMapPanel.setBackground(Color.BLACK);
            heatMapPanel.setForeground(Color.WHITE);
        } else if (item == this.normalColorMenuItem) {
            graph.setBackground(Color.WHITE);
            graph.setForeground(Color.BLACK);
            graph.setPickedLabelColor(Color.BLUE);
            graph.setVertexPaint(Color.ORANGE);
            graph.setPickedVertexPaint(Color.YELLOW);
            graph.setPickedEdgePaint(Color.BLACK);
            heatMapPanel.setForeground(Color.BLACK);
            heatMapPanel.setBackground(Color.WHITE);
        } else if (item == pearsonCalculationMenuItem) {
            correlationMethod.setValue(Correlation.PEARSON);
        } else if (item == spearmanCalculationMenuItem) {
            correlationMethod.setValue(Correlation.SPEARMAN);
        } else if (item == kendallCalculationMenuItem) {
            correlationMethod.setValue(Correlation.KENDALL);
        }
        graph.filterEdges();
        graph.repaint();
    }
}

From source file:ExSpotLight.java

public void itemStateChanged(ItemEvent event) {
    Object src = event.getSource();
    if (src == lightOnOffMenu) {
        // Turn the light on or off
        lightOnOff = lightOnOffMenu.getState();
        light.setEnable(lightOnOff);// w w w  .j a va  2  s  .c o m
        return;
    }

    // Handle all other checkboxes
    super.itemStateChanged(event);
}