package sceneapp.view;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
import java.io.IOException;
import static javafx.application.Application.launch;
public class Main extends Application {
public static Main instance;
private Stage primaryStage;
private Scene scene;
private BorderPane rootPane;
// コンストラクタ
public Main() {
instance = this;
}
// アプリケーションの起動
public static void main(String[] args) {
launch(args);
}
// ステージの作成/アプリケーションの表示
@Override
public void start(Stage primaryStage) {
this.primaryStage = primaryStage;
this.primaryStage.setTitle("JavaFXSampleSceneApp");
rootView();
indexView();
}
// Root画面
public void rootView() {
try {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(Main.class.getResource("Root.fxml"));
rootPane = (BorderPane) loader.load();
scene = new Scene(rootPane,600,430);
rootPane.getStyleClass().add("bg-color");
scene.getStylesheets().add("css/Scene.css");
primaryStage.setScene(scene);
primaryStage.show();
} catch (IOException e) {
}
}
// 画面1
public void indexView() {
try {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(Main.class.getResource("Index.fxml"));
AnchorPane anchrpane = (AnchorPane) loader.load();
rootPane.setCenter(anchrpane);
} catch (IOException e) {
}
}
// 画面2
public void view() {
try {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(Main.class.getResource("View.fxml"));
AnchorPane anchrpane = (AnchorPane) loader.load();
rootPane.setCenter(anchrpane);
} catch (IOException e) {
}
}
// 画面3
public void view2() {
try {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(Main.class.getResource("View2.fxml"));
AnchorPane anchrpane = (AnchorPane) loader.load();
rootPane.setCenter(anchrpane);
} catch (IOException e) {
}
}
// コントローラーから呼ばれメインのインスタンスを返す
public static Main getInstance(){
return instance;
}
}