connet.lolipop.jp
コントローラークラス
● FXMLファイルからイベントハンドルを受取り、メインクラスと結びつけます。

RootController.java
package sceneapp.controller;

import javafx.event.ActionEvent;
import javafx.scene.control.Alert;
 
public class RootController {

    public void siteExit(ActionEvent actionEvent) {
        System.exit(0);
    }
 
    public void siteAbout(ActionEvent actionEvent) {
        Alert alert = new Alert (Alert.AlertType.INFORMATION);
        alert.setTitle("JavaFX FXMLでシーン作成");
        alert.setHeaderText("シーン遷移を自由に操作");
        alert.setContentText("親シーンの中に複数ある子シーンの中から任意のシーンを呼び出す。");
        alert.show();
    }
    
    public void siteVersion(ActionEvent actionEvent) {
        Alert alert = new Alert (Alert.AlertType.INFORMATION);
        alert.setTitle("バージョン情報");
        alert.setHeaderText("JavaFXSampleSceneApp 1.0");
        alert.setContentText("");
        alert.show();
    }
}

IndexController.java
package sceneapp.controller;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import sceneapp.view.Main;

// メインクラス関数の呼び出し
public class IndexController {
  @FXML
  public void indexAction (ActionEvent actionEvent) {
    Main.getInstance().indexView();  
  }
	@FXML
  public void viewAction(ActionEvent actionEvent) {   
    Main.getInstance().view();
  }
  @FXML
  public void view2Action(ActionEvent actionEvent) {   
    Main.getInstance().view2();
  }
}

Search
Google


↟ このページの先頭へ