add label for current playnig
This commit is contained in:
@@ -17,6 +17,7 @@ public class MusicController {
|
|||||||
|
|
||||||
@FXML Button playButton;
|
@FXML Button playButton;
|
||||||
private boolean isPlaying = false;
|
private boolean isPlaying = false;
|
||||||
|
@FXML private Label currentplaying;
|
||||||
@FXML private ListView<Song> musicListView;
|
@FXML private ListView<Song> musicListView;
|
||||||
private ObservableList<Song> musicList = FXCollections.observableArrayList();
|
private ObservableList<Song> musicList = FXCollections.observableArrayList();
|
||||||
private ObservableList<Song> playList = FXCollections.observableArrayList();
|
private ObservableList<Song> playList = FXCollections.observableArrayList();
|
||||||
@@ -38,13 +39,16 @@ public class MusicController {
|
|||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void handlePlayAction() {
|
public void handlePlayAction() {
|
||||||
|
if (musicListView.getSelectionModel().getSelectedItem() != null) {
|
||||||
if (isPlaying) {
|
if (isPlaying) {
|
||||||
isPlaying = false;
|
isPlaying = false;
|
||||||
playButton.setText("play");
|
playButton.setText("play");
|
||||||
}
|
currentplaying.setText("");
|
||||||
else {
|
} else {
|
||||||
isPlaying = true;
|
isPlaying = true;
|
||||||
playButton.setText("pause");
|
playButton.setText("playing");
|
||||||
|
currentplaying.setText("Now playing: " + musicListView.getSelectionModel().getSelectedItem().getSongName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
<?import javafx.scene.layout.BorderPane?>
|
<?import javafx.scene.layout.BorderPane?>
|
||||||
<?import javafx.scene.layout.HBox?>
|
<?import javafx.scene.layout.HBox?>
|
||||||
|
<?import javafx.scene.layout.VBox?>
|
||||||
<?import javafx.scene.control.ListView?>
|
<?import javafx.scene.control.ListView?>
|
||||||
<?import javafx.geometry.Insets?>
|
<?import javafx.geometry.Insets?>
|
||||||
<?import javafx.scene.control.Button?>
|
<?import javafx.scene.control.Button?>
|
||||||
|
<?import javafx.scene.control.Label?>
|
||||||
<BorderPane
|
<BorderPane
|
||||||
xmlns:fx="http//javafx.com/fxml"
|
xmlns:fx="http//javafx.com/fxml"
|
||||||
fx:controller="sbu.javafx.MusicController">
|
fx:controller="sbu.javafx.MusicController">
|
||||||
@@ -15,6 +17,8 @@
|
|||||||
</center>
|
</center>
|
||||||
|
|
||||||
<bottom>
|
<bottom>
|
||||||
|
<VBox spacing="10" alignment="CENTER">
|
||||||
|
<Label fx:id="currentplaying" text=" "/>
|
||||||
<HBox spacing="10" alignment="CENTER">
|
<HBox spacing="10" alignment="CENTER">
|
||||||
<Button text="Previous" onAction="#handlePrevious"/>
|
<Button text="Previous" onAction="#handlePrevious"/>
|
||||||
<Button fx:id="playButton" text="Play" onAction="#handlePlayAction"/>
|
<Button fx:id="playButton" text="Play" onAction="#handlePlayAction"/>
|
||||||
@@ -23,6 +27,7 @@
|
|||||||
<Button text="show playList" onAction="#openPlaylistWindow"/>
|
<Button text="show playList" onAction="#openPlaylistWindow"/>
|
||||||
<Button text="show all songs" onAction="#openAllSongs"/>
|
<Button text="show all songs" onAction="#openAllSongs"/>
|
||||||
</HBox>
|
</HBox>
|
||||||
|
</VBox>
|
||||||
</bottom>
|
</bottom>
|
||||||
</BorderPane>
|
</BorderPane>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user