first commit

This commit is contained in:
2026-05-22 15:51:36 +03:30
commit e6004cce78
9 changed files with 279 additions and 0 deletions
+38
View File
@@ -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
+8
View File
@@ -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
+7
View File
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>
+14
View File
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_23" default="true" project-jdk-name="23" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
+72
View File
@@ -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.
+74
View File
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>SBU</groupId>
<artifactId>javafx</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Intro-to-javafx2</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>5.10.2</junit.version> </properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>17.0.6</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>17.0.6</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency> </dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<source>23</source>
<target>23</target>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>
<executions>
<execution>
<!-- Default configuration for running with: mvn clean javafx:run -->
<id>default-cli</id>
<configuration>
<mainClass>sbu.javafx/sbu.javafx.MusicApp</mainClass>
<launcher>app</launcher>
<jlinkZipName>app</jlinkZipName>
<jlinkImageName>app</jlinkImageName>
<noManPages>true</noManPages>
<stripDebug>true</stripDebug>
<noHeaderFiles>true</noHeaderFiles>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
+27
View File
@@ -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();
}
}
@@ -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.
}
}
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.layout.VBox?>
<VBox xmlns="http://javafx.com/fxml" alignment="CENTER" spacing="10">
<!-- TODO: Add your code here! -->
</VBox>