Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package javafx;
- import java.io.IOException;
- import java.util.Hashtable;
- import javafx.fxml.FXMLLoader;
- import javafx.scene.Parent;
- import javafx.scene.Scene;
- import javafx.stage.Stage;
- public class SceneManager {
- private static Stage stage;
- private static Hashtable<String, String> view = new Hashtable<>();
- public static void addScene(String name, String path) throws IOException{
- view.put(name, path);
- }
- public static void removeScene(String name){
- view.remove(name);
- }
- public static void renderScene(String name){
- String path="";
- try{
- path = view.get(name);
- Parent root = FXMLLoader.load(SceneManager.class.getResource(path));
- Scene scene = new Scene(root);
- stage.setScene(scene);
- stage.show();
- } catch (IOException ex){
- System.err.println("Nie można załadować pliku XML z widokiem: "+path);
- } catch (RuntimeException ex){
- System.err.println("Nazwa widoku jest nieprawidłowa");
- }
- }
- public static void setStage(Stage _stage){
- stage = _stage;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement