Code example for JSlider

Methods: getValue

0
    /** 
     * Monitor changes to the scale slider. 
     * @see javax.swing.event.ChangeListener#stateChanged(javax.swing.event.ChangeEvent) 
     */ 
    public void stateChanged(ChangeEvent evt) {
        int scale = slider.getValue();
        value.setText("x"+String.valueOf(scale));
        size.setText("Image Size: "+(width*scale)+" x "+(height*scale)+" pixels");
        preview.repaint();
    } 
     
    /** 
     * Get the current image scale reported by the slider. 
     * @return the image scale to use 
     */ 
    public double getScale() { 
        return slider.getValue();
    } 
     
    /** 
Contextual code suggestions in your IDE  Get Codota for Java