List of usage examples for javafx.util Duration subtract
public Duration subtract(Duration other)
From source file:AudioPlayer3.java
private Node createControlPanel() { final HBox hbox = new HBox(); hbox.setAlignment(Pos.CENTER);//from www . j a v a 2 s.c o m hbox.setFillHeight(false); final Button playPauseButton = createPlayPauseButton(); final Button seekStartButton = new Button(); seekStartButton.setId("seekStartButton"); seekStartButton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { seekAndUpdatePosition(Duration.ZERO); } }); final Button seekEndButton = new Button(); seekEndButton.setId("seekEndButton"); seekEndButton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { final MediaPlayer mediaPlayer = songModel.getMediaPlayer(); final Duration totalDuration = mediaPlayer.getTotalDuration(); final Duration oneSecond = Duration.seconds(1); seekAndUpdatePosition(totalDuration.subtract(oneSecond)); } }); hbox.getChildren().addAll(seekStartButton, playPauseButton, seekEndButton); return hbox; }