/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package javafxapplication1; import java.util.ArrayList; import javafx.animation.FadeTransition; import javafx.application.Application; 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.TextArea; import javafx.scene.layout.BorderPane; import javafx.scene.layout.GridPane; import javafx.scene.layout.HBox; import javafx.scene.media.Media; import javafx.scene.media.MediaPlayer; import javafx.stage.Stage; import javafx.util.Duration; /** * * @author user */ public class JavaFXApplication1 extends Application { /** * @param args the command line arguments */ final ArrayList theTracks = new ArrayList<>(0); final BorderPane bp = new BorderPane(); final GridPane gp = new GridPane(); final TextArea textArea = new TextArea(); final Button btn = new Button(); final Label label = new Label("Count:"); final Label count = new Label("-1"); final HBox box = new HBox(10); public static void main(String[] args) { launch(args); } @Override public void start(Stage primaryStage) { primaryStage.setTitle("STATUS CHECK!"); try { theTracks.add(new MediaPlayer(new Media("file:///C:/wamp/www/FYP_D07114915_SERVER/ServerAudioTracks/kevuser/Sessions/TESTSESSION/10.mp3"))); theTracks.add(new MediaPlayer(new Media("file:///C:/wamp/www/FYP_D07114915_SERVER/ServerAudioTracks/kevuser/Sessions/TESTSESSION/9.mp3"))); theTracks.add(new MediaPlayer(new Media("file:///C:/wamp/www/FYP_D07114915_SERVER/ServerAudioTracks/kevuser/Sessions/TESTSESSION/5.mp3"))); for (MediaPlayer p : theTracks){ p.setOnReady(new Runnable() { @Override public void run() { updateTextArea(); } }); } } catch (Exception e) { e.printStackTrace(); } textArea.setPrefSize(900, 100); btn.setText("CHECK"); btn.setOnAction(new EventHandler() { @Override public void handle(ActionEvent event) { updateTextArea(); } }); bp.setTop(textArea); box.getChildren().addAll(btn, label, count); bp.setBottom(box); primaryStage.setScene(new Scene(bp, 700, 100)); primaryStage.show(); } private void updateTextArea() { textArea.setText(""); for (MediaPlayer p : theTracks) { textArea.setText(textArea.getText().concat(p.getMedia().getSource() + " is " + p.getStatus() + "\n")); } int parseInt = Integer.parseInt(count.getText()); parseInt++; count.setText(String.valueOf(parseInt)); FadeTransition ft = new FadeTransition(); ft.setDuration(Duration.millis(400)); ft.setNode(textArea); ft.setFromValue(0.0); ft.setToValue(1.0); ft.play(); } }