Search in sources :

Example 1 with NetworkController

use of com.cas.sim.tis.view.controller.NetworkController in project TeachingInSimulation by ScOrPiOzzy.

the class LoginApp method start.

@Override
public void start(Stage primaryStage) throws Exception {
    // 窗口无装饰
    primaryStage.initStyle(StageStyle.TRANSPARENT);
    FXMLLoader loader = new FXMLLoader();
    loader.setResources(ResourceBundle.getBundle("i18n/messages"));
    Region loginView = loader.load(LoginApp.class.getResourceAsStream("/view/Login.fxml"));
    LoginController loginController = loader.getController();
    loader = new FXMLLoader();
    loader.setResources(ResourceBundle.getBundle("i18n/messages"));
    Region settingView = loader.load(LoginApp.class.getResourceAsStream("/view/Network.fxml"));
    NetworkController settingController = loader.getController();
    // 手动注入
    settingController.setLoginView(loginView);
    // 
    loginController.setSettingView(settingView);
    // 背景无填充
    Scene scene = new Scene(loginView);
    scene.setOnMouseDragged(e -> {
        primaryStage.setX(e.getScreenX() + xOffset);
        primaryStage.setY(e.getScreenY() + yOffset);
    });
    scene.setOnMousePressed(e -> {
        // 按下鼠标后,记录当前鼠标的坐标
        xOffset = primaryStage.getX() - e.getScreenX();
        yOffset = primaryStage.getY() - e.getScreenY();
    });
    scene.setFill(null);
    primaryStage.setScene(scene);
    primaryStage.show();
}
Also used : LoginController(com.cas.sim.tis.view.controller.LoginController) Region(javafx.scene.layout.Region) Scene(javafx.scene.Scene) FXMLLoader(javafx.fxml.FXMLLoader) NetworkController(com.cas.sim.tis.view.controller.NetworkController)

Aggregations

LoginController (com.cas.sim.tis.view.controller.LoginController)1 NetworkController (com.cas.sim.tis.view.controller.NetworkController)1 FXMLLoader (javafx.fxml.FXMLLoader)1 Scene (javafx.scene.Scene)1 Region (javafx.scene.layout.Region)1