javax.swing.event.ChangeListener Usage, Examples, Demos and Tutorials

..Code Examples of javax.swing.event.Defines an object which listens for ChangeEvents. @version 1.12 11/17/05 @author Jeff Dinkins

new Insets(0, 0, 0, 0), 0, 0));

JSlider zoomSlider = new JSlider(1, 16, DEFAULT_ZOOM);

zoomSlider.setSnapToTicks(true);

zoomSlider.putClientProperty(“JComponent.sizeVariant”, “small”);

zoomSlider.addChangeListener(new ChangeListener() {

public void stateChanged(ChangeEvent evt) {

viewer.setZoom(((JSlider) evt.getSource()).getValue());

}

});

status.add(zoomSlider, new GridBagConstraints(2, 0, 1, 1, 0.0f, 0.0f,

GridBagConstraints.LINE_START, GridBagConstraints.NONE,

new Insets(0, 0, 0, 0), 0, 0));

JLabel maxZoomLabel = new JLabel();

maxZoomLabel.setForeground(Color.WHITE);

maxZoomLabel.putClientProperty(“JComponent.sizeVariant”, “small”);

maxZoomLabel.setText(“800%”);

status.add(maxZoomLabel, new GridBagConstraints(3, 0, 1, 1, 0.0f, 0.0f,

GridBagConstraints.LINE_START, GridBagConstraints.NONE,

new Insets(0, 0, 0, 0), 0, 0));

label = new JLabel();

label.setForeground(Color.WHITE);

label.setText(“Patch scale: “);

label.putClientProperty(“JComponent.sizeVariant”, “small”);

status.add(label, new GridBagConstraints(0, 1, 1, 1, 0.0f, 0.0f,

GridBagConstraints.LINE_START, GridBagConstraints.NONE,

new Insets(0, 6, 0, 0), 0, 0));

label = new JLabel();

label.setForeground(Color.WHITE);

label.setText(“2x”);

label.putClientProperty(“JComponent.sizeVariant”, “small”);

status.add(label, new GridBagConstraints(1, 1, 1, 1, 0.0f, 0.0f,

GridBagConstraints.LINE_END, GridBagConstraints.NONE,

new Insets(0, 0, 0, 0), 0, 0));

zoomSlider = new JSlider(200, 600, (int) (DEFAULT_SCALE * 100.0f));

zoomSlider.setSnapToTicks(true);

zoomSlider.putClientProperty(“JComponent.sizeVariant”, “small”);

zoomSlider.addChangeListener(new ChangeListener() {

public void stateChanged(ChangeEvent evt) {

stretchesViewer.setScale(((JSlider) evt.getSource()).getValue() / 100.0f);

}

});

status.add(zoomSlider, new GridBagConstraints(2, 1, 1, 1, 0.0f, 0.0f,

// Action

HorizontalPanel actionPanel = new HorizontalPanel();

ButtonGroup actionButtons = new ButtonGroup();

pauseButton = new JRadioButton(pauseAction, true);

pauseButton.addChangeListener(new ChangeListener() {

public void stateChanged(ChangeEvent e) {

if (pauseButton.isSelected()) {

action = TestAction.PAUSE;

durationField.setEnabled(true);

}

}

});

stopButton = new JRadioButton(stopAction, false);

stopButton.addChangeListener(new ChangeListener() {

public void stateChanged(ChangeEvent e) {

if (stopButton.isSelected()) {

action = TestAction.STOP;

durationField.setEnabled(false);

}

}

});

stopNowButton = new JRadioButton(stopNowAction, false);

stopNowButton.addChangeListener(new ChangeListener() {

public void stateChanged(ChangeEvent e) {

if (stopNowButton.isSelected()) {

action = TestAction.STOP_NOW;

durationField.setEnabled(false);

}

repaint();

}

});

m_updateBt.setPreferredSize( m_selAttrib.getPreferredSize() );

m_jitter.addChangeListener(new ChangeListener() {

public void stateChanged(ChangeEvent ce) {

if (m_fastScroll.isSelected()) {

m_clearOSIPlottedCells = true;

}

}

});

m_plotSize.addChangeListener( new ChangeListener() {

public void stateChanged(ChangeEvent ce) {

m_plotSizeLb.setText(“PlotSize: [“+m_plotSize.getValue()+”]”);

m_plotSizeLb.setPreferredSize( m_plotLBSizeD );

m_jitter.setMaximum( m_plotSize.getValue()/5 ); //20% of cell Size

m_regenerateOSI = true;

}

});

m_pointSize.addChangeListener( new ChangeListener() {

public void stateChanged(ChangeEvent ce) {

m_pointSizeLb.setText(“PointSize: [“+m_pointSize.getValue()+”]”);

m_pointSizeLb.setPreferredSize( m_pointLBSizeD );

datapointSize = m_pointSize.getValue();

if (m_fastScroll.isSelected()) {

highMinSpinner.setValue(value.getHighMin());

highMaxSpinner.setValue(value.getHighMax());

chart.setValues(value.getTimeline(), value.getScaling());

relativeCheckBox.setSelected(value.isRelative());

lowMinSpinner.addChangeListener(new ChangeListener() {

public void stateChanged (ChangeEvent event) {

value.setLowMin((Float)lowMinSpinner.getValue());

if (!lowMaxSpinner.isVisible()) value.setLowMax((Float)lowMinSpinner.getValue());

}

});

lowMaxSpinner.addChangeListener(new ChangeListener() {

public void stateChanged (ChangeEvent event) {

value.setLowMax((Float)lowMaxSpinner.getValue());

}

});

highMinSpinner.addChangeListener(new ChangeListener() {

public void stateChanged (ChangeEvent event) {

value.setHighMin((Float)highMinSpinner.getValue());

if (!highMaxSpinner.isVisible()) value.setHighMax((Float)highMinSpinner.getValue());

}

});

highMaxSpinner.addChangeListener(new ChangeListener() {

public void stateChanged (ChangeEvent event) {

value.setHighMax((Float)highMaxSpinner.getValue());

}

});

public void actionPerformed (ActionEvent event) {

editor.getEmitter().setContinuous(continuousCheckbox.isSelected());

}

});

alignedCheckbox.addChangeListener(new ChangeListener() {

public void stateChanged (ChangeEvent event) {

editor.getEmitter().setAligned(alignedCheckbox.isSelected());

}

});

additiveCheckbox.addChangeListener(new ChangeListener() {

public void stateChanged (ChangeEvent event) {

editor.getEmitter().setAdditive(additiveCheckbox.isSelected());

}

});

behindCheckbox.addChangeListener(new ChangeListener() {

public void stateChanged (ChangeEvent event) {

editor.getEmitter().setBehind(behindCheckbox.isSelected());

}

});

/** Creates new form VariousSensorsForm */

public VariousSensorsGui(VariousSensors sensors) {

this.sensor = sensors;

initComponents();

sldLuminosity.addChangeListener(new ChangeListener() {

@Override

public void stateChanged(ChangeEvent e) {

if (!sldLuminosity.getValueIsAdjusting()) {

notifyLuminosityEvent(sldLuminosity.getValue());

updateDescription();

}

}

});

sldTemperature.addChangeListener(new ChangeListener() {

@Override

public void stateChanged(ChangeEvent e) {

if (!sldTemperature.getValueIsAdjusting()) {

notifyTemperatureEvent(sldTemperature.getValue());

HorizontalPanel numMessagesPanel = new HorizontalPanel();

numMessagesPanel.add(new JLabel(NumMessagesLabel));

ButtonGroup nmbg = new ButtonGroup();

allMessagesButton = new JRadioButton(AllMessagesLabel);

allMessagesButton.addChangeListener(new ChangeListener() {

public void stateChanged(ChangeEvent e) {

if (allMessagesButton.isSelected()) {

someMessagesField.setEnabled(false);

}

}

});

someMessagesButton = new JRadioButton();

someMessagesButton.addChangeListener(new ChangeListener() {

public void stateChanged(ChangeEvent e) {

if (someMessagesButton.isSelected()) {

someMessagesField.setEnabled(true);

}

}

c.gridwidth = GridBagConstraints.REMAINDER;

c.weightx = 1.0;

controls.add(new JSpinner(tMax), c);

tMin.addChangeListener(new ChangeListener() {

public void stateChanged(ChangeEvent e) {

double value = tMin.getNumber().doubleValue();

// if (tMax.getNumber().doubleValue() <= value) // tMax.setValue(value + 1); ((ParametricPlotter)plot).setTMin(value); } }); tMax.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { double value = tMax.getNumber().doubleValue(); // if (tMin.getNumber().doubleValue() >= value)

// tMin.setValue(value – 1);

((ParametricPlotter)plot).setTMax(value);

initializeComponents();

minSpinner.setValue(value.getLowMin());

maxSpinner.setValue(value.getLowMax());

minSpinner.addChangeListener(new ChangeListener() {

public void stateChanged (ChangeEvent event) {

value.setLowMin((Float)minSpinner.getValue());

if (!maxSpinner.isVisible()) value.setLowMax((Float)minSpinner.getValue());

}

});

maxSpinner.addChangeListener(new ChangeListener() {

public void stateChanged (ChangeEvent event) {

value.setLowMax((Float)maxSpinner.getValue());

}

});

super(“Count”, null);

initializeComponents();

maxSpinner.setValue(editor.getEmitter().getMaxParticleCount());

maxSpinner.addChangeListener(new ChangeListener() {

public void stateChanged (ChangeEvent event) {

editor.getEmitter().setMaxParticleCount((Integer)maxSpinner.getValue());

}

});

minSpinner.setValue(editor.getEmitter().getMinParticleCount());

minSpinner.addChangeListener(new ChangeListener() {

public void stateChanged (ChangeEvent event) {

editor.getEmitter().setMinParticleCount((Integer)minSpinner.getValue());

}

});

}

if (jSliderWordsCount == null) {

jSliderWordsCount = new JSlider();

jSliderWordsCount.setMinimum(5000);

jSliderWordsCount.setMaximum(150000);

jSliderWordsCount.setValue(50000);

jSliderWordsCount.addChangeListener(new ChangeListener() {

@Override

public void stateChanged(ChangeEvent arg0) {

jLabelMaxWords.setText(“Max words: (“+jSliderWordsCount.getValue()+”)”);

}

});

initializeComponents();

valueSpinner.setValue(value.getValue());

valueSpinner.addChangeListener(new ChangeListener() {

public void stateChanged (ChangeEvent event) {

value.setValue((Float)valueSpinner.getValue());

}

});

}

registerLightSlider(view);

}

private void registerLightSlider(final LightView view) {

final JSlider lightSlider = view.getLightSlider();

lightSlider.addChangeListener(new ChangeListener() {

@Override

public void stateChanged(ChangeEvent arg0) {

int value = lightSlider.getValue();

setLight(value);

}

sliderDelayInMs.setMinorTickSpacing(25);

sliderDelayInMs.setMajorTickSpacing(100);

sliderDelayInMs.setSnapToTicks(true);

sliderDelayInMs.setPaintTrack(true);

sliderDelayInMs.addChangeListener(new ChangeListener () {

@Override

public void stateChanged(ChangeEvent e) {

setLabelDelayInMsValue(getSliderDelayInMs().getValue());

}});

sliderMaxPort.setName(“”);

sliderMaxPort.setMajorTickSpacing(8192);

sliderMaxPort.setSnapToTicks(true);

sliderMaxPort.setPaintTrack(true);

sliderMaxPort.addChangeListener(new ChangeListener () {

@Override

public void stateChanged(ChangeEvent e) {

labelMaxPortValue.setText(“” + sliderMaxPort.getValue());

p3.setBorder(BorderFactory.

createTitledBorder(“Attribute selection output”));

p3.setLayout(new BorderLayout());

final JScrollPane js = new JScrollPane(m_OutText);

p3.add(js, BorderLayout.CENTER);

js.getViewport().addChangeListener(new ChangeListener() {

private int lastHeight;

public void stateChanged(ChangeEvent e) {

JViewport vp = (JViewport)e.getSource();

int h = vp.getViewSize().height;

if (h != lastHeight) { // i.e. an addition not just a user scrolling

Related Class of javax.swing.event.ChangeListener

Copyright © 2011 www.androidadb.com. All rights reserved. All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc. Contact . See also:

|

|

|

Leave a Reply

Your email address will not be published. Required fields are marked *