/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package socius.app; import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; import javafx.application.Application; import javafx.application.Platform; import javafx.event.EventHandler; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.stage.Stage; import javafx.stage.WindowEvent; /** * * @author Ana */ public class ClientBoot extends Application { private String redirecionar = "/socius/telas/login/login.fxml"; private Parent root; private Scene scene; private Stage stage; private static ClientBoot instance; private boolean resizable = false; public static ClientBoot getInstance() { if (instance == null) { if (instance == null) { instance = new ClientBoot(); } } return instance; } public Scene getScene() { return scene; } public Stage getStage() { return stage; } private void abrir() throws InterruptedException { //uso o mesmo palco e mudo de cena try { root = FXMLLoader.load(getClass().getResource(redirecionar)); scene = new Scene(root); stage.setScene(scene); stage.setResizable(resizable); //se não estiver na tela de login o stage possuira o evento //para on close que deslog o cliente do servidor Platform.setImplicitExit(true); stage.setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent t) { Platform.exit(); System.exit(0); } }); stage.show(); } catch (IOException ex) { Logger.getLogger(ClientBoot.class.getName()).log(Level.SEVERE, null, ex); } } private void esconder() { stage.hide(); } public void telaPrincipal() { resizable = true; redirecionar = "/socius/telas/principal/principal.fxml"; } public void telaLogin() { resizable = false; redirecionar = "/socius/telas/login/login.fxml"; } public void telaCadastro() { resizable = false; redirecionar = "/socius/telas/cadastro/cadastro.fxml"; } @Override public void start(Stage stage) throws Exception { this.stage = stage; abrir(); } public static void main(String[] args) { launch(args); } }