Java Reference
In-Depth Information
Stage's method setFullScreen() is invoked with a Boolean value opposite of
the currently set value. Shown here is the code needed to make a window go to full-
screen mode:
// Full screen toggle
scene.setOnMouseClicked((MouseEvent event) -> {
if (event.getClickCount() == 2) {
primaryStage.setFullScreen(!primaryStage.isFullScreen());
}
});
As you continue the steps inside the start() method, a slider control is created
by calling the convenience method createSlider() . The createSlider()
method instantiates a Slider control and adds a ChangeListener to move the
slider as the video is playing. The ChangeListener 's changed() method is in-
voked any time the slider's value changes. Once the changed() method is invoked
you will have an opportunity to see the old and new values. The following code creates
a ChangeListener to update the slider as the video is being played:
// update slider as video is progressing (later removal)
progressListener = (ObservableValue<? extends Duration>
observable,
Duration oldValue, Duration newValue)
-> {
progressSlider.setValue(newValue.toSeconds());
};
After creating the progress listener ( progressListener ), the dragged-dropped
EventHandler for the scene is created.
The goal is to determine whether the pause button was pressed before the user can
move the slider. Once a slider.isPressed() flag is determined, you will obtain
the new value to be converted to milliseconds. The dur variable is used to move the
mediaPlayer to seek the position into the video as the user slides the control left or
right. The ChangeListener 's changed() method is invoked any time the slider's
value changes. The following code is responsible for moving the seek position into the
video based on the user moving the slider.
Search WWH ::




Custom Search