Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Sound Levels Program Write a Java application named SoundLevels (held in a file

ID: 3576307 • Letter: S

Question

Sound Levels Program Write a Java application named SoundLevels (held in a file Soundlevelsjava) that creates the following GUI using JavaFX. This YouTube video demonstrates how to visually present, handle events from, and pull the values from a Slider object. When the app starts up it should initially should the following GUI: sound Reset Max: Total: o 0, ight: This GUI represents the volume of the left and right speakers of a stereo sound system (it is not really hooked up to any real speakers for this exercise s just a sample GUI interface to such a system) The GUI consists of "Left:" and Right: Label components, two Slider nts, a "Reset' Button and one more Labe to report the "Max:" and otal:" values compone The values of Max" and "Total" change as the slider thumbs are moved. Total always gives the sum of the two thumbs (each sliders values go from 0 to 100, so the maximum possible sum is 200, and the smallest sum is n Sound Levels Your Name O Reset Max: 000 Total: 200 Right: The Reset button sets both thumbs to the zero position (and the Max and Total fields both go zero, also). The Max label reports the maximum value currently held by either of the two sliders. For example, if one slider is at position 5 and the other at 65, then 65 is reported: Sound Reset Max: 65 Total: 70 Currently at position 5 Currently at position 65 Note that the window might have to be resized as the values in Max and Total change.

Explanation / Answer

//import required packages
import javafx.scene.control.Slider;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;

import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.geometry.Pos;

import javafx.scene.control.ProgressBar;
import javafx.scene.control.ProgressIndicator;

import java.awt.*;
import java.awt.event.*;
import javafx.event.*;
import javafx.scene.Group;
import javafx.scene.Scene;

public class Main extends Application {

    @Override
    public void start(Stage stage) {
        Group root = new Group();
        Scene scene = new Scene(root);
        stage.setScene(scene);
        stage.setTitle("Volume Controls");

        final Slider slider1 = new Slider();
        slider1.setMin(0);
        slider1.setMax(50);
       final Slider slider2 = new Slider();
        slider2.setMin(0);
        slider2.setMax(50);
       Button btn = new Button("Reset");


      
       
      // final ProgressBar pb = new ProgressBar(0);
        final ProgressIndicator pi1 = new ProgressIndicator(0);
       final ProgressIndicator pi2 = new ProgressIndicator(0);

        slider1.valueProperty().addListener(new ChangeListener<Number>() {
            public void changed(ObservableValue<? extends Number> ov,
                Number old_val, Number new_val) {
            
                pi1.setProgress(new_val.doubleValue()/50);
              
            }
        });


       slider2.valueProperty().addListener(new ChangeListener<Number>() {
            public void changed(ObservableValue<? extends Number> ov,
                Number old_val, Number new_val) {
               // pb.setProgress(new_val.doubleValue()/50);
                //pi1.setProgress(new_val.doubleValue()/50);
               pi2.setProgress(new_val.doubleValue()/100);
            }
        });

        final HBox hbpobject = new HBox();
        hbpobject.setSpacing(5);
        hbpobject.setAlignment(Pos.CENTER);
        hbpobject.getChildren().addAll(slider1,pi1);
       hbpobject.getChildren().addAll(slider2,pi2);
        scene.setRoot(hbpobject);
        stage.show();
    }
    public static void main(String[] args) {
        launch(args);
    }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote