forked from AdvancedProgramming1404/HW-07-JavaFX
develop
This commit is contained in:
@@ -3,21 +3,43 @@ package sbu.javafx;
|
||||
import javafx.application.Application;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
public class MusicApp extends Application {
|
||||
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());
|
||||
|
||||
FXMLLoader fxmlLoader = new FXMLLoader(
|
||||
Objects.requireNonNull(MusicApp.class.getResource("App-view.fxml"),
|
||||
"Cannot find App-view.fxml in resources (src/main/resources/sbu/javafx/)")
|
||||
);
|
||||
|
||||
Scene scene = new Scene(fxmlLoader.load(), 520, 300);
|
||||
stage.setTitle("Music Player");
|
||||
stage.setScene(scene);
|
||||
//TODO: add icon to the stage
|
||||
|
||||
try
|
||||
{
|
||||
Image icon = new Image(
|
||||
Objects.requireNonNull(MusicApp.class.getResourceAsStream("icon.png"),
|
||||
"Cannot find icon.png in resources (src/main/resources/sbu/javafx/)")
|
||||
);
|
||||
stage.getIcons().add(icon);
|
||||
}
|
||||
catch (Exception ignored) {}
|
||||
|
||||
stage.show();
|
||||
}
|
||||
|
||||
}
|
||||
public static void main(String[] args)
|
||||
{
|
||||
launch(args);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user