Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package javafx;
- import java.net.URL;
- import javafx.application.Application;
- import javafx.beans.InvalidationListener;
- import javafx.beans.Observable;
- import javafx.event.ActionEvent;
- import javafx.event.EventHandler;
- import javafx.scene.Scene;
- import javafx.scene.control.Button;
- import javafx.scene.control.Label;
- import javafx.scene.control.Slider;
- import javafx.scene.image.Image;
- import javafx.scene.layout.GridPane;
- import javafx.scene.layout.HBox;
- import javafx.scene.layout.VBox;
- import javafx.scene.media.AudioClip;
- import javafx.stage.Stage;
- public class audio extends Application {
- private AudioClip som;
- public static void main(String[] args) {
- Application.launch(args);
- }
- public void init() {
- final URL resource = getClass().getResource("exemplo.mp3");
- som = new AudioClip(resource.toExternalForm());
- }
- public void start(Stage palco) {
- Button inicB = new Button(">");
- Button sairB = new Button("||");
- final Slider volume = new Slider(0.0,1.,0.5);
- volume.setMajorTickUnit(0.1);
- volume.setShowTickLabels(true);
- inicB.setOnAction(new EventHandler<ActionEvent>() {
- public void handle(ActionEvent e) {
- som.play();
- }
- });
- sairB.setOnAction(new EventHandler<ActionEvent>() {
- public void handle(ActionEvent e) {
- som.stop();
- }
- });
- volume.valueProperty().addListener(new InvalidationListener() {
- @Override
- public void invalidated(Observable observable) {
- if(volume.isValueChanging()) {
- som.setVolume(volume.getValue());
- }
- }
- });
- GridPane PainelSlider = new GridPane();
- PainelSlider.setHgap(5);
- PainelSlider.setVgap(10);
- PainelSlider.addRow(0, new Label("Volume:"), volume);
- HBox cxBotao = new HBox(5, inicB, sairB);
- VBox raiz = new VBox(5,PainelSlider, cxBotao);
- raiz.setPrefWidth(300);
- raiz.setPrefHeight(100);
- raiz.setStyle("-fx-padding: 10;"+
- "-fx-border-package javafx;
- import java.net.URL;
- import javafx.application.Application;
- import javafx.beans.InvalidationListener;
- import javafx.beans.Observable;
- import javafx.event.ActionEvent;
- import javafx.event.EventHandler;
- import javafx.scene.Scene;
- import javafx.scene.control.Button;
- import javafx.scene.control.Label;
- import javafx.scene.control.Slider;
- import javafx.scene.image.Image;
- import javafx.scene.layout.GridPane;
- import javafx.scene.layout.HBox;
- import javafx.scene.layout.VBox;
- import javafx.scene.media.AudioClip;
- import javafx.stage.Stage;
- public class audio extends Application {
- private AudioClip som;
- public static void main(String[] args) {
- Application.launch(args);
- }
- public void init() {
- final URL resource = getClass().getResource("exemplo.mp3");
- som = new AudioClip(resource.toExternalForm());
- }
- public void start(Stage palco) {
- Button inicB = new Button(">");
- Button sairB = new Button("||");
- final Slider volume = new Slider(0.0,1.,0.5);
- volume.setMajorTickUnit(0.1);
- volume.setShowTickLabels(true);
- inicB.setOnAction(new EventHandler<ActionEvent>() {
- public void handle(ActionEvent e) {
- som.play();
- }
- });
- sairB.setOnAction(new EventHandler<ActionEvent>() {
- public void handle(ActionEvent e) {
- som.stop();
- }
- });
- volume.valueProperty().addListener(new InvalidationListener() {
- @Override
- public void invalidated(Observable observable) {
- if(volume.isValueChanging()) {
- som.setVolume(volume.getValue());
- }
- }
- });
- GridPane PainelSlider = new GridPane();
- PainelSlider.setHgap(5);
- PainelSlider.setVgap(10);
- PainelSlider.addRow(0, new Label("Volume:"), volume);
- HBox cxBotao = new HBox(5, inicB, sairB);
- VBox raiz = new VBox(5,PainelSlider, cxBotao);
- raiz.setPrefWidth(300);
- raiz.setPrefHeight(100);
- raiz.setStyle("-fx-padding: 10;"+
- "-fx-border-style: solid inside;"+
- "-fx-border-width: 2;"+
- "-fx-border-insets: 5;"+
- "-fx-border-radois: 5;"+
- "-fx-border-color: red;");
- palco.getIcons().add(new Image("file:///Users/teresacosta/M10/javafx/bin/javafx/som.png"));
- Scene cena = new Scene(raiz);
- palco.setScene(cena);
- palco.setTitle("SOM");
- palco.show();
- }
- }
- style: solid inside;"+
- "-fx-border-width: 2;"+
- "-fx-border-insets: 5;"+
- "-fx-border-radius: 5;"+
- "-fx-border-color: red;");
- palco.getIcons().add(new Image("file:///Users/teresacosta/M10/javafx/bin/javafx/som.png"));
- Scene cena = new Scene(raiz);
- palco.setScene(cena);
- palco.setTitle("SOM");
- palco.show();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement