Slide 1
Slide 2
Slide 3

Adjustment Event in java programming (V65)

No Comments

 

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: 
Copied!
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:


Ebook: 
https://softkhpc.blogspot.com/2025/05/java-programming-ebooks.html

back to top