commit e6004cce7897693940394890146b2f9145aec593 Author: RahaRokni Date: Fri May 22 15:51:36 2026 +0330 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..aa00ffa --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..001e756 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/ReadMe.md b/ReadMe.md new file mode 100644 index 0000000..7be3352 --- /dev/null +++ b/ReadMe.md @@ -0,0 +1,72 @@ +# Seventh Assignment — JavaFX Music Player Project + +This is a starter JavaFX application for a simple Music Player interface. Your goal is to design the UI and connect it to the provided controller logic to create basic music player interactions. + +## 📋 Assignment Objectives + +### Complete the following features: + +**1. Design the Music Player UI** + +Create a layout for a simple music player interface. Your UI should display at least **three songs**, each containing: + +- Song title +- Artist name +- Duration +- A **Play** button +- An **Add to Playlist** button + +**2. Connect UI Components to the Controller** + +Link your UI elements to the provided `MusicController` class: + +- Connect buttons to their corresponding controller methods. +- Ensure that clicking buttons triggers the correct actions. + +**3. Display the Currently Playing Song** + +When a user clicks a **Play** button: + +- Update a label in the UI showing the currently playing song (e.g., "Now Playing: Song Title"). + +**4. Implement a Playlist** + +When the **Add to Playlist** button is clicked: + +- Add the selected song to a playlist data structure (e.g., an `ArrayList`). + +**5. Create a Playlist Page** + +Add a **"View Playlist"** button to the main UI: + +- When clicked, switch to a **new scene** that displays the playlist. +- Use `stage.setScene(...)` to switch between scenes. +- Show the playlist content using a `ListView` or any other layout. + + +## 🎨 UI Design Reference + +To help you get started, refer to the layout below. Your application should have a similar, clean, and simple structure: + +![Music Player UI Layout](https://uploadkon.ir/uploads/85a922_26music.png) + +*(Note: This is a wireframe. You are encouraged to keep your implementation simple and focus on functionality.)* + + +## ⭐ Bonus Tasks (Optional) + +**The core requirements above do not include actual audio playback.** The following tasks are optional (Bonus) and should only be attempted if you have completed the core requirements. + +**1. Play Functionality** + +- Implement actual audio playback using JavaFX `Media` and `MediaPlayer` classes. + +**2. Add Visual Feedback** + +- When a song is playing, change the row style or update the **Play** button text to "Playing". + +**3. Dark Mode / Light Mode** + +- Add a toggle button to switch between two CSS stylesheets (e.g., `dark.css` and `light.css`) at runtime. + + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..eba2d41 --- /dev/null +++ b/pom.xml @@ -0,0 +1,74 @@ + + + 4.0.0 + + SBU + javafx + 1.0-SNAPSHOT + Intro-to-javafx2 + + + UTF-8 +5.10.2 + + + + org.openjfx + javafx-controls + 17.0.6 + + + org.openjfx + javafx-fxml + 17.0.6 + + + + org.junit.jupiter + junit-jupiter-api + ${junit.version} + test + + + org.junit.jupiter + junit-jupiter-engine + ${junit.version} + test + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.13.0 + + 23 + 23 + + + + org.openjfx + javafx-maven-plugin + 0.0.8 + + + + default-cli + + sbu.javafx/sbu.javafx.MusicApp + app + app + app + true + true + true + + + + + + + \ No newline at end of file diff --git a/src/main/java/sbu/javafx/MusicApp.java b/src/main/java/sbu/javafx/MusicApp.java new file mode 100644 index 0000000..44efe95 --- /dev/null +++ b/src/main/java/sbu/javafx/MusicApp.java @@ -0,0 +1,27 @@ +package sbu.javafx; + +import javafx.application.Application; +import javafx.fxml.FXMLLoader; +import javafx.scene.Scene; +import javafx.stage.Stage; + +import java.io.IOException; + +public class MusicApp extends Application { + + @Override + public void start(Stage stage) throws IOException + { + FXMLLoader fxmlLoader = new FXMLLoader(MusicApp.class.getResource("App-view.fxml")); + Scene scene = new Scene(fxmlLoader.load()); + stage.setTitle("Music Player"); + stage.setScene(scene); + //TODO: add icon to the stage + stage.show(); + } + + public static void main(String[] args) + { + launch(); + } +} diff --git a/src/main/java/sbu/javafx/MusicController.java b/src/main/java/sbu/javafx/MusicController.java new file mode 100644 index 0000000..5da27a9 --- /dev/null +++ b/src/main/java/sbu/javafx/MusicController.java @@ -0,0 +1,31 @@ +package sbu.javafx; + +import javafx.fxml.FXML; +import javafx.event.ActionEvent; +import javafx.scene.control.Label; +import javafx.scene.input.MouseEvent; +import javafx.scene.layout.VBox; + +public class MusicController { + + // TODO: Define your UI components using the @FXML annotation. + + //TODO: Implement the logic to play a song. This method should update the UI to show which song is currently playing. + + @FXML + public void handlePlayAction() { + //Update labels, change button icons, etc. + } + + //TODO: Logic to add a specific song to the user's playlist. + + public void addToPlaylist(String songName) { + //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. + + public void openPlaylistWindow() { + //Create a new stage and show the playlist UI. + } +} diff --git a/src/main/resources/sbu/javafx/App-view.fxml b/src/main/resources/sbu/javafx/App-view.fxml new file mode 100644 index 0000000..306c8d3 --- /dev/null +++ b/src/main/resources/sbu/javafx/App-view.fxml @@ -0,0 +1,8 @@ + + + + + + + +