3 Commits
Author SHA1 Message Date
Z.Gharagozloo.M a535e0a52a Launcher and test completed. 2026-06-02 14:12:04 +03:30
Z.Gharagozloo.M 58bc71aeb1 MusicController and MusicApp completed. 2026-06-02 14:09:51 +03:30
Z.Gharagozloo.M 1de7da14ac App_view completed. 2026-06-02 13:50:22 +03:30
6 changed files with 147 additions and 28 deletions
+1 -1
View File
@@ -8,7 +8,7 @@
</list> </list>
</option> </option>
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_23" default="true" project-jdk-name="23" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_25" default="true" project-jdk-name="25" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" /> <output url="file://$PROJECT_DIR$/out" />
</component> </component>
</project> </project>
Generated
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
+2
View File
@@ -5,4 +5,6 @@ import javafx.application.Application;
public class Launcher { public class Launcher {
public static void main(String[] args) { public static void main(String[] args) {
// TODO: Launch the JavaFX application by calling Application.launch(Main.class) } // TODO: Launch the JavaFX application by calling Application.launch(Main.class) }
Application.launch(MusicApp.class, args);
}
} }
+18 -5
View File
@@ -3,21 +3,34 @@ package sbu.javafx;
import javafx.application.Application; import javafx.application.Application;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Stage; import javafx.stage.Stage;
import java.io.IOException; import java.io.IOException;
import java.util.Objects;
public class MusicApp extends Application { public class MusicApp extends Application {
@Override @Override
public void start(Stage stage) throws IOException public void start(Stage stage) throws IOException {
{
FXMLLoader fxmlLoader = new FXMLLoader(MusicApp.class.getResource("App-view.fxml")); FXMLLoader fxmlLoader = new FXMLLoader(MusicApp.class.getResource("App-view.fxml"));
Scene scene = new Scene(fxmlLoader.load()); Scene scene = new Scene(fxmlLoader.load(), 600, 550);
stage.setTitle("Music Player");
stage.setTitle("🎵 Music Player");
try {
Image icon = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/icons/music_icon.png")));
stage.getIcons().add(icon);
} catch (Exception e) {
System.out.println("Icon not found, continuing without icon.");
}
stage.setScene(scene); stage.setScene(scene);
//TODO: add icon to the stage stage.setResizable(false);
stage.show(); stage.show();
} }
public static void main(String[] args) {
launch(args);
}
} }
+42 -14
View File
@@ -1,31 +1,59 @@
package sbu.javafx; package sbu.javafx;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.event.ActionEvent;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.input.MouseEvent; import java.util.ArrayList;
import javafx.scene.layout.VBox;
public class MusicController { public class MusicController {
// TODO: Define your UI components using the @FXML annotation. @FXML
private Label nowPlayingLabel;
//TODO: Implement the logic to play a song. This method should update the UI to show which song is currently playing. private ArrayList<String> playlist = new ArrayList<>();
@FXML @FXML
public void handlePlayAction() { public void playSong1() {
//Update labels, change button icons, etc. nowPlayingLabel.setText("🎵 Now Playing: Bohemian Rhapsody - Queen");
} }
//TODO: Logic to add a specific song to the user's playlist. @FXML
public void playSong2() {
public void addToPlaylist(String songName) { nowPlayingLabel.setText("🎵 Now Playing: Imagine - John Lennon");
//Add the song to a list or update a ListView.
} }
// TODO:This method should open a new window or change the current scene to display the "Playlist" page. @FXML
public void playSong3() {
nowPlayingLabel.setText("🎵 Now Playing: Billie Jean - Michael Jackson");
}
public void openPlaylistWindow() { @FXML
//Create a new stage and show the playlist UI. public void addToPlaylist1() {
playlist.add("Bohemian Rhapsody - Queen");
System.out.println("✓ Added to playlist: Bohemian Rhapsody");
}
@FXML
public void addToPlaylist2() {
playlist.add("Imagine - John Lennon");
System.out.println("✓ Added to playlist: Imagine");
}
@FXML
public void addToPlaylist3() {
playlist.add("Billie Jean - Michael Jackson");
System.out.println("✓ Added to playlist: Billie Jean");
}
@FXML
public void viewPlaylist() {
System.out.println("\n📋 ===== MY PLAYLIST ===== 📋");
if (playlist.isEmpty()) {
System.out.println("Playlist is empty! Add some songs.");
} else {
for (int i = 0; i < playlist.size(); i++) {
System.out.println((i + 1) + ". " + playlist.get(i));
}
}
System.out.println("==========================\n");
} }
} }
+72 -2
View File
@@ -1,8 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.Separator?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?> <?import javafx.scene.layout.VBox?>
<VBox xmlns="http://javafx.com/fxml" alignment="CENTER" spacing="10">
<!-- TODO: Add your code here! --> <VBox xmlns="http://javafx.com/fxml"
xmlns:fx="http://javafx.com/fxml"
fx:controller="sbu.javafx.MusicController"
alignment="TOP_CENTER"
spacing="15"
style="-fx-background-color: linear-gradient(to bottom, #1a1a2e, #16213e); -fx-padding: 20;">
<Label text="🎵 MUSIC PLAYER 🎵"
style="-fx-font-size: 28px; -fx-font-weight: bold; -fx-text-fill: white;">
<VBox.margin>
<Insets top="10" bottom="10"/>
</VBox.margin>
</Label>
<Separator style="-fx-background-color: #e94560;"/>
<HBox spacing="20" alignment="CENTER_LEFT"
style="-fx-padding: 15; -fx-background-color: #0f3460; -fx-background-radius: 10;">
<VBox HBox.hgrow="ALWAYS">
<Label text="Bohemian Rhapsody" style="-fx-text-fill: white; -fx-font-size: 16px; -fx-font-weight: bold;"/>
<Label text="Queen" style="-fx-text-fill: #aaaaaa; -fx-font-size: 13px;"/>
<Label text="5:55" style="-fx-text-fill: #888888; -fx-font-size: 12px;"/>
</VBox>
<Button fx:id="playBtn1" text="▶ Play"
style="-fx-background-color: #e94560; -fx-text-fill: white; -fx-cursor: hand; -fx-background-radius: 20; -fx-padding: 8 15;"
onAction="#playSong1"/>
<Button fx:id="addBtn1" text=" Add"
style="-fx-background-color: #533483; -fx-text-fill: white; -fx-cursor: hand; -fx-background-radius: 20; -fx-padding: 8 15;"
onAction="#addToPlaylist1"/>
</HBox>
<HBox spacing="20" alignment="CENTER_LEFT"
style="-fx-padding: 15; -fx-background-color: #0f3460; -fx-background-radius: 10;">
<VBox HBox.hgrow="ALWAYS">
<Label text="Imagine" style="-fx-text-fill: white; -fx-font-size: 16px; -fx-font-weight: bold;"/>
<Label text="John Lennon" style="-fx-text-fill: #aaaaaa; -fx-font-size: 13px;"/>
<Label text="3:04" style="-fx-text-fill: #888888; -fx-font-size: 12px;"/>
</VBox>
<Button fx:id="playBtn2" text="▶ Play"
style="-fx-background-color: #e94560; -fx-text-fill: white; -fx-cursor: hand; -fx-background-radius: 20; -fx-padding: 8 15;"
onAction="#playSong2"/>
<Button fx:id="addBtn2" text=" Add"
style="-fx-background-color: #533483; -fx-text-fill: white; -fx-cursor: hand; -fx-background-radius: 20; -fx-padding: 8 15;"
onAction="#addToPlaylist2"/>
</HBox>
<HBox spacing="20" alignment="CENTER_LEFT"
style="-fx-padding: 15; -fx-background-color: #0f3460; -fx-background-radius: 10;">
<VBox HBox.hgrow="ALWAYS">
<Label text="Billie Jean" style="-fx-text-fill: white; -fx-font-size: 16px; -fx-font-weight: bold;"/>
<Label text="Michael Jackson" style="-fx-text-fill: #aaaaaa; -fx-font-size: 13px;"/>
<Label text="4:54" style="-fx-text-fill: #888888; -fx-font-size: 12px;"/>
</VBox>
<Button fx:id="playBtn3" text="▶ Play"
style="-fx-background-color: #e94560; -fx-text-fill: white; -fx-cursor: hand; -fx-background-radius: 20; -fx-padding: 8 15;"
onAction="#playSong3"/>
<Button fx:id="addBtn3" text=" Add"
style="-fx-background-color: #533483; -fx-text-fill: white; -fx-cursor: hand; -fx-background-radius: 20; -fx-padding: 8 15;"
onAction="#addToPlaylist3"/>
</HBox>
<Label fx:id="nowPlayingLabel" text="💿 Now Playing: -"
style="-fx-text-fill: #e94560; -fx-font-size: 14px; -fx-font-style: italic; -fx-alignment: center;"/>
<Button text="📋 View Playlist"
style="-fx-background-color: #e94560; -fx-text-fill: white; -fx-font-size: 14px; -fx-cursor: hand; -fx-background-radius: 25; -fx-padding: 10 20;"
onAction="#viewPlaylist"/>
</VBox> </VBox>