getValueIsAdjusting()

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to previous page   go to home page   go to next page

Answer:

Many; the exact number depends on how fast the knob is moved.

getValueIsAdjusting()

In the previous application the number in the text box changes continuously as the knob is moved. Usually this is desirable. But sometimes the application calls for a great deal of work and you don't want to do it for each change event. There are (potentially) hundreds of change events generated in moving the knob from one value to the next. While the value is still changing the listener should discard the event.

boolean getValueIsAdjusting()

This method returns true while the knob is still moving.

QUESTION 13:

Fill in the blank so that the following fragment changes the text field only after the knob has stopped.

source = (JSlider)evt.getSource() ;

if ( __source.__________ )
{
  if ( source.getName()().equals("sliderA") )
    textA.setText( source.getValue() + " " );
  if ( source.getName()().equals("sliderB") )
    textB.setText( source.getValue() + " " );
}