AdjustmentEvent
AdjustmentEvent is an event that occurs when the value of an adjustable GUI component changes, such as a Scrollbar.
This event is generated whenever the user moves the scrollbar thumb, clicks on the arrows, or clicks inside the scrollbar track.
Example:
Source Code:
import java.awt.Color;
private void updateColor() {
int r = scrollRed.getValue();
int g = scrollGreen.getValue();
int b = scrollBlue.getValue();
labelRed.setText("Red: " + r);
labelGreen.setText("Green: " + g);
labelBlue.setText("Blue: " + b);
panelColor.setBackground(new Color(r, g, b));
}
private void scrollRedAdjustmentValueChanged(java.awt.event.AdjustmentEvent evt) {
updateColor();
}
private void scrollGreenAdjustmentValueChanged(java.awt.event.AdjustmentEvent evt) {
updateColor();
}
private void scrollBlueAdjustmentValueChanged(java.awt.event.AdjustmentEvent evt) {
updateColor();
}
Result:
Watch the video:

