Skip to main content

Clase PruebaVentanas:

package pruebaventanas;

import java.io.IOException;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;

public class PruebaVentanas extends Application {

    private Stage stagePrincipal;
    private AnchorPane rootPane;

    @Override
    public void start(Stage stagePrincipal) throws Exception {
        this.stagePrincipal = stagePrincipal;
        mostrarVentanaPrincipal();

    }

    /*
     * cargamos la ventana principal
     */
    public void mostrarVentanaPrincipal() {
        try {
            FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("VentanaPrincipal.fxml"));
            rootPane=(AnchorPane) loader.load();
            Scene scene = new Scene(rootPane);
            stagePrincipal.setTitle(".: TEAM :.");
            stagePrincipal.setScene(scene);
            VentanaPrincipalController controller = loader.getController();
            controller.setProgramaPrincipal(this);
            stagePrincipal.show();
        } catch (IOException e) {
        }
    }

    public void mostrarVentanaSecundaria() {
        try {
            FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("cMenuTutor.fxml"));
            AnchorPane ventanaDos = (AnchorPane) loader.load();
            Stage ventana2 = new Stage();
            ventana2.setTitle("Bienvenido Tutor");
            ventana2.initOwner(stagePrincipal);
            Scene scene = new Scene(ventanaDos);
            ventana2.setScene(scene);
            cMenuTutorController controller = loader.getController();
            controller.setStagePrincipal(ventana2);
            ventana2.show();

        } catch (Exception e) {
        }
    }
    public void mostrarPerfilTutor() {
        try {
           // System.out.println("holla");
            FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("cPerfilTutor.fxml"));
          // System.out.println("jjja");
            AnchorPane ventanaTres = (AnchorPane) loader.load();
            Stage ventana3 = new Stage();
            ventana3.setTitle("Bienvenido Tutor");
            ventana3.initOwner(stagePrincipal);
            Scene scene3 = new Scene(ventanaTres);
            ventana3.setScene(scene3);
            cPerfilTutorController controller = loader.getController();
            controller.setStagePrincipal(ventana3);
            ventana3.show();
            /**FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("VentanaPrincipal.fxml"));
            rootPane=(AnchorPane) loader.load();
            Scene scene = new Scene(rootPane);
            stagePrincipal.setTitle(".: TEAM :.");
            stagePrincipal.setScene(scene);
            VentanaPrincipalController controller = loader.getController();
            controller.setProgramaPrincipal(this);
            stagePrincipal.show();*/

        } catch (Exception e) {
        }
    }
    
    public void mostrarMenuAdministrador() {
        try {
            System.out.println("holla");
            FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("cMenuAdministrador.fxml"));
            System.out.println("jjja");
            AnchorPane ventanaCuatro = (AnchorPane) loader.load();
            Stage ventana4 = new Stage();
            ventana4.setTitle("Bienvenido Administrador");
            ventana4.initOwner(stagePrincipal);
            Scene scene4 = new Scene(ventanaCuatro);
            ventana4.setScene(scene4);
            cMenuAdministradorController controller = loader.getController();
            controller.setStagePrincipal(ventana4);
            ventana4.show();

        } catch (Exception e) {
        }
    }
    
    public void mostrarPerfilAdministrador() {
        try {
           // System.out.println("holla");
            FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("cPerfilAdministrador.fxml"));
          // System.out.println("jjja");
            AnchorPane ventanaCinco = (AnchorPane) loader.load();
            Stage ventana5 = new Stage();
            ventana5.setTitle("Bienvenido Administrador");
            ventana5.initOwner(stagePrincipal);
            Scene scene5 = new Scene(ventanaCinco);
            ventana5.setScene(scene5);
            cPerfilAdministradorController controller = loader.getController();
            controller.setStagePrincipal(ventana5);
            ventana5.show();

        } catch (Exception e) {
        }
    }

    public static void main(String[] args) {
        launch(args);
    }
}

***************************************

FXML:

<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane id="AnchorPane" prefHeight="350" prefWidth="320" xmlns:fx="http://javafx.com/fxml" fx:controller="pruebaventanas.VentanaPrincipalController">
    <children>
        <Label layoutX="100" layoutY="20" minWidth="120" minHeight="25" fx:id="label" text="HyperGerät Presenta"  />
        <Label layoutX="135" layoutY="45" minWidth="120" minHeight="25" fx:id="labelt" text=" TEAM"  />
        <TextField layoutX="120" layoutY="120" minWidth="100" minHeight="25" fx:id="usuario"    />
        <TextField layoutX="120" layoutY="160" minWidth="100" minHeight="25" fx:id="contrasena"    />
        <Label layoutX="50" layoutY="120" minHeight="16" minWidth="69" fx:id="label2" text="Usuario"/>
        <Label layoutX="50" layoutY="160" minHeight="16" minWidth="69" fx:id="label3" text="Contraseña"/>
        <Button layoutX="126" layoutY="235" text="Abrir Ventana" onAction="#ventanaNew" fx:id="button" />
    </children>
</AnchorPane>
********************************************************

Clase VentanaPrincipalController:

package pruebaventanas;

import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;

public class VentanaPrincipalController implements Initializable {

    private PruebaVentanas ProgramaPrincipal;

    @FXML
    private void ventanaNew(ActionEvent event) {
        System.out.println("Entra boton");
        validaUsuario();
        ProgramaPrincipal.mostrarMenuAdministrador();
        
    }

    public void setProgramaPrincipal(PruebaVentanas ProgramaPrincipal) {
        this.ProgramaPrincipal = ProgramaPrincipal;
    }

    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }
    
    private void validaUsuario(){
       
    }
}
**********************************************************************

FXML:

<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.net.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane id="AnchorPane" prefHeight="350" prefWidth="320" xmlns:fx="http://javafx.com/fxml" fx:controller="pruebaventanas.cMenuTutorController">
<children>
        <Button layoutX="126" layoutY="120" text="Mi Perfil" onAction="#perfilTutor" fx:id="perfil" />
        <Button layoutX="126" layoutY="160" text="Actividades" onAction="#salirVentana" fx:id="actividades" />
        <Button layoutX="200" layoutY="280" text="Cerrar  Sesion" onAction="#salirVentana" fx:id="cerrarSesion" />
    </children>
</AnchorPane>
***********************************************************************

Clase cMenuTutorController:

package pruebaventanas;

import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.stage.Stage;

public class cMenuTutorController implements Initializable {
    private Stage stagePrincipal;
    private PruebaVentanas prueba = new PruebaVentanas();
    
    public void setStagePrincipal(Stage stagePrincipal) {
        this.stagePrincipal = stagePrincipal;
    }
    
    @FXML
    private void salirVentana(ActionEvent event) {
        stagePrincipal.close();
    }
    
    @FXML
    private void perfilTutor(ActionEvent event) {
        try{
            System.out.println("Cambia Algo");
            prueba.mostrarPerfilTutor();
        }
        catch(Exception e){
            String xD = e.getMessage();
            System.out.println(xD);
        }
        
    }
    
    @FXML
    private void menuTutorAdmin(ActionEvent event) {
        try{
            System.out.println("Cambia Algo");
            prueba.mostrarPerfilTutor();
        }
        catch(Exception e){
            String xD = e.getMessage();
            System.out.println(xD);
        }
        
    }
    
    
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }    
}
**********************************************************************

FXML:

<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.net.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane id="AnchorPane" prefHeight="400.0" prefWidth="600.0" styleClass="mainFxmlClass" xmlns:fx="http://javafx.com/fxml/1" fx:controller="pruebaventanas.cPerfilAdministradorController">
    <stylesheets>
        <URL value="@ventanados.css"/>
    </stylesheets>
    <children>
            <Button layoutX="25" layoutY="125" fx:id="consultar"   text="Consultar mi Informacion"  />
            <Button layoutX="25" layoutY="200" fx:id="modifica" text="Modificar Informacion"  />
            <Button layoutX="25" layoutY="300" fx:id="atras" text="⬅"  />
    </children>
</AnchorPane>
**************************************************************************

Clase cPerfilAdministradorController:

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package pruebaventanas;

import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.Initializable;
import javafx.stage.Stage;

/**
 * FXML Controller class
 *
 * @author Otoniel Aguirre
 */
public class cPerfilAdministradorController implements Initializable {

    private Stage stagePrincipal;
    
    public void setStagePrincipal(Stage stagePrincipal) {
        this.stagePrincipal = stagePrincipal;
    }
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }    
    
}
*******************************************************************

FXML:

<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.net.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane id="AnchorPane" prefHeight="400.0" prefWidth="600.0" styleClass="mainFxmlClass" xmlns:fx="http://javafx.com/fxml/1" fx:controller="pruebaventanas.cPerfilTutorController">
    <stylesheets>
        <URL value="@ventanados.css"/>
    </stylesheets>
    <children>
            <Button layoutX="25" layoutY="125" fx:id="consulta"   text="Consultar mi Informacion"  />
            <Button layoutX="25" layoutY="200" fx:id="modificar" text="Modificar Informacion"  />
            <Button layoutX="25" layoutY="300" fx:id="atras" text="⬅"  />
    </children>
</AnchorPane>
*****************************************************************************

Clase cPerfilTutorController:

import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.Initializable;
import javafx.stage.Stage;

/**
 * FXML Controller class
 *
 * @author Otoniel Aguirre
 */
public class cPerfilTutorController implements Initializable {
    private Stage stagePrincipal;
    
    public void setStagePrincipal(Stage stagePrincipal) {
        this.stagePrincipal = stagePrincipal;
    }

    /**
     * Initializes the controller class.
     */
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }    
    
}
*****************************************************************************
package pruebaventanas;

import java.io.IOException;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;

public class PruebaVentanas extends Application {

    private Stage stagePrincipal;
    private AnchorPane rootPane;

    @Override
    public void start(Stage stagePrincipal) throws Exception {
        this.stagePrincipal = stagePrincipal;
        mostrarVentanaPrincipal();

    }

    /*
     * cargamos la ventana principal
     */
    public void mostrarVentanaPrincipal() {
        try {
            FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("VentanaPrincipal.fxml"));
            rootPane=(AnchorPane) loader.load();
            Scene scene = new Scene(rootPane);
            stagePrincipal.setTitle(".: TEAM :.");
            stagePrincipal.setScene(scene);
            VentanaPrincipalController controller = loader.getController();
            controller.setProgramaPrincipal(this);
            stagePrincipal.show();
        } catch (IOException e) {
        }
    }

    public void mostrarVentanaSecundaria() {
        try {
            FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("cMenuTutor.fxml"));
            AnchorPane ventanaDos = (AnchorPane) loader.load();
            Stage ventana2 = new Stage();
            ventana2.setTitle("Bienvenido Tutor");
            ventana2.initOwner(stagePrincipal);
            Scene scene = new Scene(ventanaDos);
            ventana2.setScene(scene);
            cMenuTutorController controller = loader.getController();
            controller.setStagePrincipal(ventana2);
            ventana2.show();

        } catch (Exception e) {
        }
    }
    public void mostrarPerfilTutor() {
        try {
           // System.out.println("holla");
            FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("cPerfilTutor.fxml"));
          // System.out.println("jjja");
            AnchorPane ventanaTres = (AnchorPane) loader.load();
            Stage ventana3 = new Stage();
            ventana3.setTitle("Bienvenido Tutor");
            ventana3.initOwner(stagePrincipal);
            Scene scene3 = new Scene(ventanaTres);
            ventana3.setScene(scene3);
            cPerfilTutorController controller = loader.getController();
            controller.setStagePrincipal(ventana3);
            ventana3.show();
            /**FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("VentanaPrincipal.fxml"));
            rootPane=(AnchorPane) loader.load();
            Scene scene = new Scene(rootPane);
            stagePrincipal.setTitle(".: TEAM :.");
            stagePrincipal.setScene(scene);
            VentanaPrincipalController controller = loader.getController();
            controller.setProgramaPrincipal(this);
            stagePrincipal.show();*/

        } catch (Exception e) {
        }
    }
    
    public void mostrarMenuAdministrador() {
        try {
            System.out.println("holla");
            FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("cMenuAdministrador.fxml"));
            System.out.println("jjja");
            AnchorPane ventanaCuatro = (AnchorPane) loader.load();
            Stage ventana4 = new Stage();
            ventana4.setTitle("Bienvenido Administrador");
            ventana4.initOwner(stagePrincipal);
            Scene scene4 = new Scene(ventanaCuatro);
            ventana4.setScene(scene4);
            cMenuAdministradorController controller = loader.getController();
            controller.setStagePrincipal(ventana4);
            ventana4.show();

        } catch (Exception e) {
        }
    }
    
    public void mostrarPerfilAdministrador() {
        try {
           // System.out.println("holla");
            FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("cPerfilAdministrador.fxml"));
          // System.out.println("jjja");
            AnchorPane ventanaCinco = (AnchorPane) loader.load();
            Stage ventana5 = new Stage();
            ventana5.setTitle("Bienvenido Administrador");
            ventana5.initOwner(stagePrincipal);
            Scene scene5 = new Scene(ventanaCinco);
            ventana5.setScene(scene5);
            cPerfilAdministradorController controller = loader.getController();
            controller.setStagePrincipal(ventana5);
            ventana5.show();

        } catch (Exception e) {
        }
    }

    public static void main(String[] args) {
        launch(args);
    }
}

***************************************
<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane id="AnchorPane" prefHeight="350" prefWidth="320" xmlns:fx="http://javafx.com/fxml" fx:controller="pruebaventanas.VentanaPrincipalController">
    <children>
        <Label layoutX="100" layoutY="20" minWidth="120" minHeight="25" fx:id="label" text="HyperGerät Presenta"  />
        <Label layoutX="135" layoutY="45" minWidth="120" minHeight="25" fx:id="labelt" text=" TEAM"  />
        <TextField layoutX="120" layoutY="120" minWidth="100" minHeight="25" fx:id="usuario"    />
        <TextField layoutX="120" layoutY="160" minWidth="100" minHeight="25" fx:id="contrasena"    />
        <Label layoutX="50" layoutY="120" minHeight="16" minWidth="69" fx:id="label2" text="Usuario"/>
        <Label layoutX="50" layoutY="160" minHeight="16" minWidth="69" fx:id="label3" text="Contraseña"/>
        <Button layoutX="126" layoutY="235" text="Abrir Ventana" onAction="#ventanaNew" fx:id="button" />
    </children>
</AnchorPane>
********************************************************
package pruebaventanas;

import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;

public class VentanaPrincipalController implements Initializable {

    private PruebaVentanas ProgramaPrincipal;

    @FXML
    private void ventanaNew(ActionEvent event) {
        System.out.println("Entra boton");
        validaUsuario();
        ProgramaPrincipal.mostrarMenuAdministrador();
        
    }

    public void setProgramaPrincipal(PruebaVentanas ProgramaPrincipal) {
        this.ProgramaPrincipal = ProgramaPrincipal;
    }

    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }
    
    private void validaUsuario(){
       
    }
}
**********************************************************************
<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.net.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane id="AnchorPane" prefHeight="350" prefWidth="320" xmlns:fx="http://javafx.com/fxml" fx:controller="pruebaventanas.cMenuTutorController">
<children>
        <Button layoutX="126" layoutY="120" text="Mi Perfil" onAction="#perfilTutor" fx:id="perfil" />
        <Button layoutX="126" layoutY="160" text="Actividades" onAction="#salirVentana" fx:id="actividades" />
        <Button layoutX="200" layoutY="280" text="Cerrar  Sesion" onAction="#salirVentana" fx:id="cerrarSesion" />
    </children>
</AnchorPane>
***********************************************************************
package pruebaventanas;

import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.stage.Stage;

public class cMenuTutorController implements Initializable {
    private Stage stagePrincipal;
    private PruebaVentanas prueba = new PruebaVentanas();
    
    public void setStagePrincipal(Stage stagePrincipal) {
        this.stagePrincipal = stagePrincipal;
    }
    
    @FXML
    private void salirVentana(ActionEvent event) {
        stagePrincipal.close();
    }
    
    @FXML
    private void perfilTutor(ActionEvent event) {
        try{
            System.out.println("Cambia Algo");
            prueba.mostrarPerfilTutor();
        }
        catch(Exception e){
            String xD = e.getMessage();
            System.out.println(xD);
        }
        
    }
    
    @FXML
    private void menuTutorAdmin(ActionEvent event) {
        try{
            System.out.println("Cambia Algo");
            prueba.mostrarPerfilTutor();
        }
        catch(Exception e){
            String xD = e.getMessage();
            System.out.println(xD);
        }
        
    }
    
    
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }    
}
**********************************************************************
<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.net.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane id="AnchorPane" prefHeight="400.0" prefWidth="600.0" styleClass="mainFxmlClass" xmlns:fx="http://javafx.com/fxml/1" fx:controller="pruebaventanas.cPerfilAdministradorController">
    <stylesheets>
        <URL value="@ventanados.css"/>
    </stylesheets>
    <children>
            <Button layoutX="25" layoutY="125" fx:id="consultar"   text="Consultar mi Informacion"  />
            <Button layoutX="25" layoutY="200" fx:id="modifica" text="Modificar Informacion"  />
            <Button layoutX="25" layoutY="300" fx:id="atras" text="⬅"  />
    </children>
</AnchorPane>
**************************************************************************
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package pruebaventanas;

import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.Initializable;
import javafx.stage.Stage;

/**
 * FXML Controller class
 *
 * @author Otoniel Aguirre
 */
public class cPerfilAdministradorController implements Initializable {

    private Stage stagePrincipal;
    
    public void setStagePrincipal(Stage stagePrincipal) {
        this.stagePrincipal = stagePrincipal;
    }
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }    
    
}
*******************************************************************
<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.net.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane id="AnchorPane" prefHeight="400.0" prefWidth="600.0" styleClass="mainFxmlClass" xmlns:fx="http://javafx.com/fxml/1" fx:controller="pruebaventanas.cPerfilTutorController">
    <stylesheets>
        <URL value="@ventanados.css"/>
    </stylesheets>
    <children>
            <Button layoutX="25" layoutY="125" fx:id="consulta"   text="Consultar mi Informacion"  />
            <Button layoutX="25" layoutY="200" fx:id="modificar" text="Modificar Informacion"  />
            <Button layoutX="25" layoutY="300" fx:id="atras" text="⬅"  />
    </children>
</AnchorPane>
*****************************************************************************

import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.Initializable;
import javafx.stage.Stage;

/**
 * FXML Controller class
 *
 * @author Otoniel Aguirre
 */
public class cPerfilTutorController implements Initializable {
    private Stage stagePrincipal;
    
    public void setStagePrincipal(Stage stagePrincipal) {
        this.stagePrincipal = stagePrincipal;
    }

    /**
     * Initializes the controller class.
     */
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }    
    
}
*****************************************************************************

Clase PruebaVentanas:

package pruebaventanas;

import java.io.IOException;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;

public class PruebaVentanas extends Application {

    private Stage stagePrincipal;
    private AnchorPane rootPane;

    @Override
    public void start(Stage stagePrincipal) throws Exception {
        this.stagePrincipal = stagePrincipal;
        mostrarVentanaPrincipal();

    }

    /*
     * cargamos la ventana principal
     */
    public void mostrarVentanaPrincipal() {
        try {
            FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("VentanaPrincipal.fxml"));
            rootPane=(AnchorPane) loader.load();
            Scene scene = new Scene(rootPane);
            stagePrincipal.setTitle(".: TEAM :.");
            stagePrincipal.setScene(scene);
            VentanaPrincipalController controller = loader.getController();
            controller.setProgramaPrincipal(this);
            stagePrincipal.show();
        } catch (IOException e) {
        }
    }

    public void mostrarVentanaSecundaria() {
        try {
            FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("cMenuTutor.fxml"));
            AnchorPane ventanaDos = (AnchorPane) loader.load();
            Stage ventana2 = new Stage();
            ventana2.setTitle("Bienvenido Tutor");
            ventana2.initOwner(stagePrincipal);
            Scene scene = new Scene(ventanaDos);
            ventana2.setScene(scene);
            cMenuTutorController controller = loader.getController();
            controller.setStagePrincipal(ventana2);
            ventana2.show();

        } catch (Exception e) {
        }
    }
    public void mostrarPerfilTutor() {
        try {
           // System.out.println("holla");
            FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("cPerfilTutor.fxml"));
          // System.out.println("jjja");
            AnchorPane ventanaTres = (AnchorPane) loader.load();
            Stage ventana3 = new Stage();
            ventana3.setTitle("Bienvenido Tutor");
            ventana3.initOwner(stagePrincipal);
            Scene scene3 = new Scene(ventanaTres);
            ventana3.setScene(scene3);
            cPerfilTutorController controller = loader.getController();
            controller.setStagePrincipal(ventana3);
            ventana3.show();
            /**FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("VentanaPrincipal.fxml"));
            rootPane=(AnchorPane) loader.load();
            Scene scene = new Scene(rootPane);
            stagePrincipal.setTitle(".: TEAM :.");
            stagePrincipal.setScene(scene);
            VentanaPrincipalController controller = loader.getController();
            controller.setProgramaPrincipal(this);
            stagePrincipal.show();*/

        } catch (Exception e) {
        }
    }
    
    public void mostrarMenuAdministrador() {
        try {
            System.out.println("holla");
            FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("cMenuAdministrador.fxml"));
            System.out.println("jjja");
            AnchorPane ventanaCuatro = (AnchorPane) loader.load();
            Stage ventana4 = new Stage();
            ventana4.setTitle("Bienvenido Administrador");
            ventana4.initOwner(stagePrincipal);
            Scene scene4 = new Scene(ventanaCuatro);
            ventana4.setScene(scene4);
            cMenuAdministradorController controller = loader.getController();
            controller.setStagePrincipal(ventana4);
            ventana4.show();

        } catch (Exception e) {
        }
    }
    
    public void mostrarPerfilAdministrador() {
        try {
           // System.out.println("holla");
            FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("cPerfilAdministrador.fxml"));
          // System.out.println("jjja");
            AnchorPane ventanaCinco = (AnchorPane) loader.load();
            Stage ventana5 = new Stage();
            ventana5.setTitle("Bienvenido Administrador");
            ventana5.initOwner(stagePrincipal);
            Scene scene5 = new Scene(ventanaCinco);
            ventana5.setScene(scene5);
            cPerfilAdministradorController controller = loader.getController();
            controller.setStagePrincipal(ventana5);
            ventana5.show();

        } catch (Exception e) {
        }
    }

    public static void main(String[] args) {
        launch(args);
    }
}

FXML:

<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane id="AnchorPane" prefHeight="350" prefWidth="320" xmlns:fx="http://javafx.com/fxml" fx:controller="pruebaventanas.VentanaPrincipalController">
    <children>
        <Label layoutX="100" layoutY="20" minWidth="120" minHeight="25" fx:id="label" text="HyperGerät Presenta"  />
        <Label layoutX="135" layoutY="45" minWidth="120" minHeight="25" fx:id="labelt" text=" TEAM"  />
        <TextField layoutX="120" layoutY="120" minWidth="100" minHeight="25" fx:id="usuario"    />
        <TextField layoutX="120" layoutY="160" minWidth="100" minHeight="25" fx:id="contrasena"    />
        <Label layoutX="50" layoutY="120" minHeight="16" minWidth="69" fx:id="label2" text="Usuario"/>
        <Label layoutX="50" layoutY="160" minHeight="16" minWidth="69" fx:id="label3" text="Contraseña"/>
        <Button layoutX="126" layoutY="235" text="Abrir Ventana" onAction="#ventanaNew" fx:id="button" />
    </children>
</AnchorPane>

Clase VentanaPrincipalController:

package pruebaventanas;

import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;

public class VentanaPrincipalController implements Initializable {

    private PruebaVentanas ProgramaPrincipal;

    @FXML
    private void ventanaNew(ActionEvent event) {
        System.out.println("Entra boton");
        validaUsuario();
        ProgramaPrincipal.mostrarMenuAdministrador();
        
    }

    public void setProgramaPrincipal(PruebaVentanas ProgramaPrincipal) {
        this.ProgramaPrincipal = ProgramaPrincipal;
    }

    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }
    
    private void validaUsuario(){
       
    }
}

FXML:

<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.net.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane id="AnchorPane" prefHeight="350" prefWidth="320" xmlns:fx="http://javafx.com/fxml" fx:controller="pruebaventanas.cMenuTutorController">
<children>
        <Button layoutX="126" layoutY="120" text="Mi Perfil" onAction="#perfilTutor" fx:id="perfil" />
        <Button layoutX="126" layoutY="160" text="Actividades" onAction="#salirVentana" fx:id="actividades" />
        <Button layoutX="200" layoutY="280" text="Cerrar  Sesion" onAction="#salirVentana" fx:id="cerrarSesion" />
    </children>
</AnchorPane>

Clase cMenuTutorController:

package pruebaventanas;

import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.stage.Stage;

public class cMenuTutorController implements Initializable {
    private Stage stagePrincipal;
    private PruebaVentanas prueba = new PruebaVentanas();
    
    public void setStagePrincipal(Stage stagePrincipal) {
        this.stagePrincipal = stagePrincipal;
    }
    
    @FXML
    private void salirVentana(ActionEvent event) {
        stagePrincipal.close();
    }
    
    @FXML
    private void perfilTutor(ActionEvent event) {
        try{
            System.out.println("Cambia Algo");
            prueba.mostrarPerfilTutor();
        }
        catch(Exception e){
            String xD = e.getMessage();
            System.out.println(xD);
        }
        
    }
    
    @FXML
    private void menuTutorAdmin(ActionEvent event) {
        try{
            System.out.println("Cambia Algo");
            prueba.mostrarPerfilTutor();
        }
        catch(Exception e){
            String xD = e.getMessage();
            System.out.println(xD);
        }
        
    }
    
    
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }    
}

FXML:

<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.net.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane id="AnchorPane" prefHeight="400.0" prefWidth="600.0" styleClass="mainFxmlClass" xmlns:fx="http://javafx.com/fxml/1" fx:controller="pruebaventanas.cPerfilAdministradorController">
    <stylesheets>
        <URL value="@ventanados.css"/>
    </stylesheets>
    <children>
            <Button layoutX="25" layoutY="125" fx:id="consultar"   text="Consultar mi Informacion"  />
            <Button layoutX="25" layoutY="200" fx:id="modifica" text="Modificar Informacion"  />
            <Button layoutX="25" layoutY="300" fx:id="atras" text="⬅"  />
    </children>
</AnchorPane>

Clase cPerfilAdministradorController:

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package pruebaventanas;

import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.Initializable;
import javafx.stage.Stage;

/**
 * FXML Controller class
 *
 * @author Otoniel Aguirre
 */
public class cPerfilAdministradorController implements Initializable {

    private Stage stagePrincipal;
    
    public void setStagePrincipal(Stage stagePrincipal) {
        this.stagePrincipal = stagePrincipal;
    }
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }    
    
}

FXML:

<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.net.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane id="AnchorPane" prefHeight="400.0" prefWidth="600.0" styleClass="mainFxmlClass" xmlns:fx="http://javafx.com/fxml/1" fx:controller="pruebaventanas.cPerfilTutorController">
    <stylesheets>
        <URL value="@ventanados.css"/>
    </stylesheets>
    <children>
            <Button layoutX="25" layoutY="125" fx:id="consulta"   text="Consultar mi Informacion"  />
            <Button layoutX="25" layoutY="200" fx:id="modificar" text="Modificar Informacion"  />
            <Button layoutX="25" layoutY="300" fx:id="atras" text="⬅"  />
    </children>
</AnchorPane>

Clase cPerfilTutorController:

import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.Initializable;
import javafx.stage.Stage;

/**
 * FXML Controller class
 *
 * @author Otoniel Aguirre
 */
public class cPerfilTutorController implements Initializable {
    private Stage stagePrincipal;
    
    public void setStagePrincipal(Stage stagePrincipal) {
        this.stagePrincipal = stagePrincipal;
    }

    /**
     * Initializes the controller class.
     */
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }    
    
}
Mejorando gramática y formato. indentando código
Origen Enlace
user13558
user13558

¿Como¿Cómo puedo cambiar de frameun frame a otro cerrando el primer frame en javaFX? Tengo el siguiente codigo pero no funciona, no me abre las otras ventanas

package pruebaventanas;

import java.io.IOException; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Scene; import javafx.scene.layout.AnchorPane; import javafx.stage.Stage;

public class PruebaVentanas extends Application {

private Stage stagePrincipal;
private AnchorPane rootPane;

@Override
public void start(Stage stagePrincipal) throws Exception {
    this.stagePrincipal = stagePrincipal;
    mostrarVentanaPrincipal();

}

/*
 * cargamos la ventana principal
 */
public void mostrarVentanaPrincipal() {
    try {
        FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("VentanaPrincipal.fxml"));
        rootPane=(AnchorPane) loader.load();
        Scene scene = new Scene(rootPane);
        stagePrincipal.setTitle(".: TEAM :.");
        stagePrincipal.setScene(scene);
        VentanaPrincipalController controller = loader.getController();
        controller.setProgramaPrincipal(this);
        stagePrincipal.show();
    } catch (IOException e) {
    }
}

public void mostrarVentanaSecundaria() {
    try {
        FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("cMenuTutor.fxml"));
        AnchorPane ventanaDos = (AnchorPane) loader.load();
        Stage ventana2 = new Stage();
        ventana2.setTitle("Bienvenido Tutor");
        ventana2.initOwner(stagePrincipal);
        Scene scene = new Scene(ventanaDos);
        ventana2.setScene(scene);
        cMenuTutorController controller = loader.getController();
        controller.setStagePrincipal(ventana2);
        ventana2.show();

    } catch (Exception e) {
    }
}
public void mostrarPerfilTutor() {
    try {
       // System.out.println("holla");
        FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("cPerfilTutor.fxml"));
      // System.out.println("jjja");
        AnchorPane ventanaTres = (AnchorPane) loader.load();
        Stage ventana3 = new Stage();
        ventana3.setTitle("Bienvenido Tutor");
        ventana3.initOwner(stagePrincipal);
        Scene scene3 = new Scene(ventanaTres);
        ventana3.setScene(scene3);
        cPerfilTutorController controller = loader.getController();
        controller.setStagePrincipal(ventana3);
        ventana3.show();
        /**FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("VentanaPrincipal.fxml"));
        rootPane=(AnchorPane) loader.load();
        Scene scene = new Scene(rootPane);
        stagePrincipal.setTitle(".: TEAM :.");
        stagePrincipal.setScene(scene);
        VentanaPrincipalController controller = loader.getController();
        controller.setProgramaPrincipal(this);
        stagePrincipal.show();*/

    } catch (Exception e) {
    }
}

public void mostrarMenuAdministrador() {
    try {
        System.out.println("holla");
        FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("cMenuAdministrador.fxml"));
        System.out.println("jjja");
        AnchorPane ventanaCuatro = (AnchorPane) loader.load();
        Stage ventana4 = new Stage();
        ventana4.setTitle("Bienvenido Administrador");
        ventana4.initOwner(stagePrincipal);
        Scene scene4 = new Scene(ventanaCuatro);
        ventana4.setScene(scene4);
        cMenuAdministradorController controller = loader.getController();
        controller.setStagePrincipal(ventana4);
        ventana4.show();

    } catch (Exception e) {
    }
}

public void mostrarPerfilAdministrador() {
    try {
       // System.out.println("holla");
        FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("cPerfilAdministrador.fxml"));
      // System.out.println("jjja");
        AnchorPane ventanaCinco = (AnchorPane) loader.load();
        Stage ventana5 = new Stage();
        ventana5.setTitle("Bienvenido Administrador");
        ventana5.initOwner(stagePrincipal);
        Scene scene5 = new Scene(ventanaCinco);
        ventana5.setScene(scene5);
        cPerfilAdministradorController controller = loader.getController();
        controller.setStagePrincipal(ventana5);
        ventana5.show();

    } catch (Exception e) {
    }
}

public static void main(String[] args) {
    launch(args);
}

}


********************************************************package pruebaventanas;

import java.net.URL; import java.util.ResourceBundle; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.fxml.Initializable;

public class VentanaPrincipalController implements Initializableframe en {

private PruebaVentanas ProgramaPrincipal;

@FXML
private void ventanaNew(ActionEvent event) {
    System.out.println("Entra boton");
    validaUsuario();
    ProgramaPrincipal.mostrarMenuAdministrador();
    
}

public void setProgramaPrincipal(PruebaVentanas ProgramaPrincipal) {
    this.ProgramaPrincipal = ProgramaPrincipal;
}

@Override
public void initialize(URL url, ResourceBundle rb) {
    // TODO
}

private void validaUsuario(){
   
}

}


***********************************************************************package pruebaventanas;

import java.net.URL; import java.util.ResourceBundle; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.fxml.Initializable; import javafx.stage.Stage;javaFX?

public class cMenuTutorController implements Initializable { private Stage stagePrincipal; private PruebaVentanas prueba = new PruebaVentanas();Tengo el siguiente código, pero no funciona, no me abre las otras ventanas:

public void setStagePrincipal(Stage stagePrincipal) {
    this.stagePrincipal =package stagePrincipal;
}pruebaventanas;

@FXMLimport java.io.IOException;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;

public class PruebaVentanas extends Application {

    private Stage stagePrincipal;
    private AnchorPane rootPane;

    @Override
    public void salirVentanastart(ActionEventStage eventstagePrincipal) throws Exception {
        this.stagePrincipal = stagePrincipal;
        mostrarVentanaPrincipal();

    }

    /*
     * cargamos la ventana principal
     */
    public void mostrarVentanaPrincipal() {
        try {
            FXMLLoader loader = new FXMLLoader(PruebaVentanas.closeclass.getResource("VentanaPrincipal.fxml"));
            rootPane=(AnchorPane) loader.load();
            Scene scene = new Scene(rootPane);
            stagePrincipal.setTitle(".: TEAM :.");
            stagePrincipal.setScene(scene);
            VentanaPrincipalController controller = loader.getController();
            controller.setProgramaPrincipal(this);
            stagePrincipal.show();
        } catch (IOException e) {
        }
    }

    public void mostrarVentanaSecundaria() {
        try {
            FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("cMenuTutor.fxml"));
            AnchorPane ventanaDos = (AnchorPane) loader.load();
            Stage ventana2 = new Stage();
            ventana2.setTitle("Bienvenido Tutor");
            ventana2.initOwner(stagePrincipal);
            Scene scene = new Scene(ventanaDos);
            ventana2.setScene(scene);
            cMenuTutorController controller = loader.getController();
            controller.setStagePrincipal(ventana2);
            ventana2.show();

        } catch (Exception e) {
        }
    }
    public void mostrarPerfilTutor() {
        try {
           // System.out.println("holla");
            FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("cPerfilTutor.fxml"));
          // System.out.println("jjja");
            AnchorPane ventanaTres = (AnchorPane) loader.load();
            Stage ventana3 = new Stage();
            ventana3.setTitle("Bienvenido Tutor");
            ventana3.initOwner(stagePrincipal);
            Scene scene3 = new Scene(ventanaTres);
            ventana3.setScene(scene3);
            cPerfilTutorController controller = loader.getController();
            controller.setStagePrincipal(ventana3);
            ventana3.show();
            /**FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("VentanaPrincipal.fxml"));
            rootPane=(AnchorPane) loader.load();
            Scene scene = new Scene(rootPane);
            stagePrincipal.setTitle(".: TEAM :.");
            stagePrincipal.setScene(scene);
            VentanaPrincipalController controller = loader.getController();
            controller.setProgramaPrincipal(this);
            stagePrincipal.show();*/

        } catch (Exception e) {
        }
    }
    
    public void mostrarMenuAdministrador() {
        try {
            System.out.println("holla");
            FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("cMenuAdministrador.fxml"));
            System.out.println("jjja");
            AnchorPane ventanaCuatro = (AnchorPane) loader.load();
            Stage ventana4 = new Stage();
            ventana4.setTitle("Bienvenido Administrador");
            ventana4.initOwner(stagePrincipal);
            Scene scene4 = new Scene(ventanaCuatro);
            ventana4.setScene(scene4);
            cMenuAdministradorController controller = loader.getController();
            controller.setStagePrincipal(ventana4);
            ventana4.show();

        } catch (Exception e) {
        }
    }
    
    public void mostrarPerfilAdministrador() {
        try {
           // System.out.println("holla");
            FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("cPerfilAdministrador.fxml"));
          // System.out.println("jjja");
            AnchorPane ventanaCinco = (AnchorPane) loader.load();
            Stage ventana5 = new Stage();
            ventana5.setTitle("Bienvenido Administrador");
            ventana5.initOwner(stagePrincipal);
            Scene scene5 = new Scene(ventanaCinco);
            ventana5.setScene(scene5);
            cPerfilAdministradorController controller = loader.getController();
            controller.setStagePrincipal(ventana5);
            ventana5.show();

        } catch (Exception e) {
        }
    }

    public static void main(String[] args) {
        launch(args);
    }
}

@FXML***************************************
private<?xml voidversion="1.0" perfilTutor(ActionEventencoding="UTF-8"?>

<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane id="AnchorPane" prefHeight="350" prefWidth="320" xmlns:fx="http://javafx.com/fxml" fx:controller="pruebaventanas.VentanaPrincipalController">
    <children>
        <Label layoutX="100" layoutY="20" minWidth="120" minHeight="25" fx:id="label" text="HyperGerät Presenta"  />
        <Label layoutX="135" layoutY="45" minWidth="120" minHeight="25" fx:id="labelt" text=" TEAM"  />
        <TextField layoutX="120" layoutY="120" minWidth="100" minHeight="25" fx:id="usuario"    />
        <TextField layoutX="120" layoutY="160" minWidth="100" minHeight="25" fx:id="contrasena"    />
        <Label layoutX="50" layoutY="120" minHeight="16" minWidth="69" fx:id="label2" text="Usuario"/>
        <Label layoutX="50" layoutY="160" minHeight="16" minWidth="69" fx:id="label3" text="Contraseña"/>
        <Button layoutX="126" layoutY="235" text="Abrir Ventana" onAction="#ventanaNew" fx:id="button" />
    </children>
</AnchorPane>
********************************************************
package pruebaventanas;

import java.net.URL;
import java.util.ResourceBundle;
import javafx.event).ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;

public class VentanaPrincipalController implements Initializable { 

    tryprivate PruebaVentanas ProgramaPrincipal;

    @FXML
    private void ventanaNew(ActionEvent event) {
        System.out.println("Cambia"Entra Algo"boton");
        pruebavalidaUsuario();
        ProgramaPrincipal.mostrarPerfilTutormostrarMenuAdministrador();
        
    }
 
    catchpublic void setProgramaPrincipal(ExceptionPruebaVentanas eProgramaPrincipal) {
        String xDthis.ProgramaPrincipal = e.getMessage();ProgramaPrincipal;
    }

    System.out.println@Override
    public void initialize(xDURL url, ResourceBundle rb); {
        // TODO
    }
    
    private void validaUsuario(){
       
    }
}
**********************************************************************
<?xml version="1.0" encoding="UTF-8"?>

@FXML<?import java.lang.*?>
private<?import voidjava.net.*?>
<?import menuTutorAdmin(ActionEventjava.util.*?>
<?import event)javafx.scene.*?>
<?import {javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane id="AnchorPane" prefHeight="350" try{prefWidth="320" xmlns:fx="http://javafx.com/fxml" fx:controller="pruebaventanas.cMenuTutorController">
<children>
        System<Button layoutX="126" layoutY="120" text="Mi Perfil" onAction="#perfilTutor" fx:id="perfil" />
        <Button layoutX="126" layoutY="160" text="Actividades" onAction="#salirVentana" fx:id="actividades" />
        <Button layoutX="200" layoutY="280" text="Cerrar  Sesion" onAction="#salirVentana" fx:id="cerrarSesion" />
    </children>
</AnchorPane>
***********************************************************************
package pruebaventanas;

import java.outnet.println("CambiaURL;
import Algo");java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.stage.Stage;

public class cMenuTutorController implements Initializable {
    private Stage stagePrincipal;
    private PruebaVentanas prueba.mostrarPerfilTutor = new PruebaVentanas();
    
    public void setStagePrincipal(Stage stagePrincipal) {
        this.stagePrincipal = stagePrincipal;
    }
    catch(Exception e){
     @FXML
   String xDprivate =void e.getMessagesalirVentana(ActionEvent event); {
        System.outstagePrincipal.printlnclose(xD);
    }
    
    @FXML
    private void perfilTutor(ActionEvent event) {
        try{
            System.out.println("Cambia Algo");
            prueba.mostrarPerfilTutor();
        }
        catch(Exception e){
            String xD = e.getMessage();
            System.out.println(xD);
        }
        
    }
    
    @FXML
    private void menuTutorAdmin(ActionEvent event) {
        try{
            System.out.println("Cambia Algo");
            prueba.mostrarPerfilTutor();
        }
        catch(Exception e){
            String xD = e.getMessage();
            System.out.println(xD);
        }
        
    }
    
    
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }    
}
**********************************************************************
<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.net.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane id="AnchorPane" prefHeight="400.0" prefWidth="600.0" styleClass="mainFxmlClass" xmlns:fx="http://javafx.com/fxml/1" fx:controller="pruebaventanas.cPerfilAdministradorController">
    <stylesheets>
        <URL value="@ventanados.css"/>
    </stylesheets>
    <children>
            <Button layoutX="25" layoutY="125" fx:id="consultar"   text="Consultar mi Informacion"  />
            <Button layoutX="25" layoutY="200" fx:id="modifica" text="Modificar Informacion"  />
            <Button layoutX="25" layoutY="300" fx:id="atras" text="⬅"  />
    </children>
</AnchorPane>
**************************************************************************
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package pruebaventanas;

import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.Initializable;
import javafx.stage.Stage;

/**
 * FXML Controller class
 *
 * @author Otoniel Aguirre
 */
public class cPerfilAdministradorController implements Initializable {

    private Stage stagePrincipal;
    
    public void setStagePrincipal(Stage stagePrincipal) {
        this.stagePrincipal = stagePrincipal;
    }
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }    
    
}
*******************************************************************
<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.net.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane id="AnchorPane" prefHeight="400.0" prefWidth="600.0" styleClass="mainFxmlClass" xmlns:fx="http://javafx.com/fxml/1" fx:controller="pruebaventanas.cPerfilTutorController">
    <stylesheets>
        <URL value="@ventanados.css"/>
    </stylesheets>
    <children>
            <Button layoutX="25" layoutY="125" fx:id="consulta"   text="Consultar mi Informacion"  />
            <Button layoutX="25" layoutY="200" fx:id="modificar" text="Modificar Informacion"  />
            <Button layoutX="25" layoutY="300" fx:id="atras" text="⬅"  />
    </children>
</AnchorPane>
*****************************************************************************

import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.Initializable;
import javafx.stage.Stage;

/**
 * FXML Controller class
 *
 * @author Otoniel Aguirre
 */
public class cPerfilTutorController implements Initializable {
    private Stage stagePrincipal;
    
    public void setStagePrincipal(Stage stagePrincipal) {
        this.stagePrincipal = stagePrincipal;
    }

    /**
     * Initializes the controller class.
     */
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }    
    
}
*****************************************************************************

}


**************************************************************************/** To change this license header, choose License Headers in Project Properties.* To change this template file, choose Tools | Templates* and open the template in the editor.*/package pruebaventanas;

import java.net.URL; import java.util.ResourceBundle; import javafx.fxml.Initializable; import javafx.stage.Stage;

/**

  • FXML Controller class

  • @author Otoniel Aguirre */ public class cPerfilAdministradorController implements Initializable {

    private Stage stagePrincipal;

    public void setStagePrincipal(Stage stagePrincipal) { this.stagePrincipal = stagePrincipal; } @Override public void initialize(URL url, ResourceBundle rb) { // TODO }

}


*****************************************************************************

import java.net.URL; import java.util.ResourceBundle; import javafx.fxml.Initializable; import javafx.stage.Stage;

/**

  • FXML Controller class

  • @author Otoniel Aguirre */ public class cPerfilTutorController implements Initializable { private Stage stagePrincipal;

    public void setStagePrincipal(Stage stagePrincipal) { this.stagePrincipal = stagePrincipal; }

    /**

    • Initializes the controller class. */ @Override public void initialize(URL url, ResourceBundle rb) { // TODO }

}


El problema es que no me abre la siguiente ventana, ni me muestra nada.

¿Como puedo cambiar de frame a otro cerrando el primer frame en javaFX? Tengo el siguiente codigo pero no funciona, no me abre las otras ventanas

package pruebaventanas;

import java.io.IOException; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Scene; import javafx.scene.layout.AnchorPane; import javafx.stage.Stage;

public class PruebaVentanas extends Application {

private Stage stagePrincipal;
private AnchorPane rootPane;

@Override
public void start(Stage stagePrincipal) throws Exception {
    this.stagePrincipal = stagePrincipal;
    mostrarVentanaPrincipal();

}

/*
 * cargamos la ventana principal
 */
public void mostrarVentanaPrincipal() {
    try {
        FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("VentanaPrincipal.fxml"));
        rootPane=(AnchorPane) loader.load();
        Scene scene = new Scene(rootPane);
        stagePrincipal.setTitle(".: TEAM :.");
        stagePrincipal.setScene(scene);
        VentanaPrincipalController controller = loader.getController();
        controller.setProgramaPrincipal(this);
        stagePrincipal.show();
    } catch (IOException e) {
    }
}

public void mostrarVentanaSecundaria() {
    try {
        FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("cMenuTutor.fxml"));
        AnchorPane ventanaDos = (AnchorPane) loader.load();
        Stage ventana2 = new Stage();
        ventana2.setTitle("Bienvenido Tutor");
        ventana2.initOwner(stagePrincipal);
        Scene scene = new Scene(ventanaDos);
        ventana2.setScene(scene);
        cMenuTutorController controller = loader.getController();
        controller.setStagePrincipal(ventana2);
        ventana2.show();

    } catch (Exception e) {
    }
}
public void mostrarPerfilTutor() {
    try {
       // System.out.println("holla");
        FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("cPerfilTutor.fxml"));
      // System.out.println("jjja");
        AnchorPane ventanaTres = (AnchorPane) loader.load();
        Stage ventana3 = new Stage();
        ventana3.setTitle("Bienvenido Tutor");
        ventana3.initOwner(stagePrincipal);
        Scene scene3 = new Scene(ventanaTres);
        ventana3.setScene(scene3);
        cPerfilTutorController controller = loader.getController();
        controller.setStagePrincipal(ventana3);
        ventana3.show();
        /**FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("VentanaPrincipal.fxml"));
        rootPane=(AnchorPane) loader.load();
        Scene scene = new Scene(rootPane);
        stagePrincipal.setTitle(".: TEAM :.");
        stagePrincipal.setScene(scene);
        VentanaPrincipalController controller = loader.getController();
        controller.setProgramaPrincipal(this);
        stagePrincipal.show();*/

    } catch (Exception e) {
    }
}

public void mostrarMenuAdministrador() {
    try {
        System.out.println("holla");
        FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("cMenuAdministrador.fxml"));
        System.out.println("jjja");
        AnchorPane ventanaCuatro = (AnchorPane) loader.load();
        Stage ventana4 = new Stage();
        ventana4.setTitle("Bienvenido Administrador");
        ventana4.initOwner(stagePrincipal);
        Scene scene4 = new Scene(ventanaCuatro);
        ventana4.setScene(scene4);
        cMenuAdministradorController controller = loader.getController();
        controller.setStagePrincipal(ventana4);
        ventana4.show();

    } catch (Exception e) {
    }
}

public void mostrarPerfilAdministrador() {
    try {
       // System.out.println("holla");
        FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("cPerfilAdministrador.fxml"));
      // System.out.println("jjja");
        AnchorPane ventanaCinco = (AnchorPane) loader.load();
        Stage ventana5 = new Stage();
        ventana5.setTitle("Bienvenido Administrador");
        ventana5.initOwner(stagePrincipal);
        Scene scene5 = new Scene(ventanaCinco);
        ventana5.setScene(scene5);
        cPerfilAdministradorController controller = loader.getController();
        controller.setStagePrincipal(ventana5);
        ventana5.show();

    } catch (Exception e) {
    }
}

public static void main(String[] args) {
    launch(args);
}

}


********************************************************package pruebaventanas;

import java.net.URL; import java.util.ResourceBundle; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.fxml.Initializable;

public class VentanaPrincipalController implements Initializable {

private PruebaVentanas ProgramaPrincipal;

@FXML
private void ventanaNew(ActionEvent event) {
    System.out.println("Entra boton");
    validaUsuario();
    ProgramaPrincipal.mostrarMenuAdministrador();
    
}

public void setProgramaPrincipal(PruebaVentanas ProgramaPrincipal) {
    this.ProgramaPrincipal = ProgramaPrincipal;
}

@Override
public void initialize(URL url, ResourceBundle rb) {
    // TODO
}

private void validaUsuario(){
   
}

}


***********************************************************************package pruebaventanas;

import java.net.URL; import java.util.ResourceBundle; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.fxml.Initializable; import javafx.stage.Stage;

public class cMenuTutorController implements Initializable { private Stage stagePrincipal; private PruebaVentanas prueba = new PruebaVentanas();

public void setStagePrincipal(Stage stagePrincipal) {
    this.stagePrincipal = stagePrincipal;
}

@FXML
private void salirVentana(ActionEvent event) {
    stagePrincipal.close();
}

@FXML
private void perfilTutor(ActionEvent event) {
    try{
        System.out.println("Cambia Algo");
        prueba.mostrarPerfilTutor();
    }
    catch(Exception e){
        String xD = e.getMessage();
        System.out.println(xD);
    }
    
}

@FXML
private void menuTutorAdmin(ActionEvent event) {
    try{
        System.out.println("Cambia Algo");
        prueba.mostrarPerfilTutor();
    }
    catch(Exception e){
        String xD = e.getMessage();
        System.out.println(xD);
    }
    
}


@Override
public void initialize(URL url, ResourceBundle rb) {
    // TODO
}    

}


**************************************************************************/** To change this license header, choose License Headers in Project Properties.* To change this template file, choose Tools | Templates* and open the template in the editor.*/package pruebaventanas;

import java.net.URL; import java.util.ResourceBundle; import javafx.fxml.Initializable; import javafx.stage.Stage;

/**

  • FXML Controller class

  • @author Otoniel Aguirre */ public class cPerfilAdministradorController implements Initializable {

    private Stage stagePrincipal;

    public void setStagePrincipal(Stage stagePrincipal) { this.stagePrincipal = stagePrincipal; } @Override public void initialize(URL url, ResourceBundle rb) { // TODO }

}


*****************************************************************************

import java.net.URL; import java.util.ResourceBundle; import javafx.fxml.Initializable; import javafx.stage.Stage;

/**

  • FXML Controller class

  • @author Otoniel Aguirre */ public class cPerfilTutorController implements Initializable { private Stage stagePrincipal;

    public void setStagePrincipal(Stage stagePrincipal) { this.stagePrincipal = stagePrincipal; }

    /**

    • Initializes the controller class. */ @Override public void initialize(URL url, ResourceBundle rb) { // TODO }

}


El problema es que no me abre la siguiente ventana, ni me muestra nada

¿Cómo puedo cambiar de un frame a otro cerrando el primer frame en javaFX?

Tengo el siguiente código, pero no funciona, no me abre las otras ventanas:

package pruebaventanas;

import java.io.IOException;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;

public class PruebaVentanas extends Application {

    private Stage stagePrincipal;
    private AnchorPane rootPane;

    @Override
    public void start(Stage stagePrincipal) throws Exception {
        this.stagePrincipal = stagePrincipal;
        mostrarVentanaPrincipal();

    }

    /*
     * cargamos la ventana principal
     */
    public void mostrarVentanaPrincipal() {
        try {
            FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("VentanaPrincipal.fxml"));
            rootPane=(AnchorPane) loader.load();
            Scene scene = new Scene(rootPane);
            stagePrincipal.setTitle(".: TEAM :.");
            stagePrincipal.setScene(scene);
            VentanaPrincipalController controller = loader.getController();
            controller.setProgramaPrincipal(this);
            stagePrincipal.show();
        } catch (IOException e) {
        }
    }

    public void mostrarVentanaSecundaria() {
        try {
            FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("cMenuTutor.fxml"));
            AnchorPane ventanaDos = (AnchorPane) loader.load();
            Stage ventana2 = new Stage();
            ventana2.setTitle("Bienvenido Tutor");
            ventana2.initOwner(stagePrincipal);
            Scene scene = new Scene(ventanaDos);
            ventana2.setScene(scene);
            cMenuTutorController controller = loader.getController();
            controller.setStagePrincipal(ventana2);
            ventana2.show();

        } catch (Exception e) {
        }
    }
    public void mostrarPerfilTutor() {
        try {
           // System.out.println("holla");
            FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("cPerfilTutor.fxml"));
          // System.out.println("jjja");
            AnchorPane ventanaTres = (AnchorPane) loader.load();
            Stage ventana3 = new Stage();
            ventana3.setTitle("Bienvenido Tutor");
            ventana3.initOwner(stagePrincipal);
            Scene scene3 = new Scene(ventanaTres);
            ventana3.setScene(scene3);
            cPerfilTutorController controller = loader.getController();
            controller.setStagePrincipal(ventana3);
            ventana3.show();
            /**FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("VentanaPrincipal.fxml"));
            rootPane=(AnchorPane) loader.load();
            Scene scene = new Scene(rootPane);
            stagePrincipal.setTitle(".: TEAM :.");
            stagePrincipal.setScene(scene);
            VentanaPrincipalController controller = loader.getController();
            controller.setProgramaPrincipal(this);
            stagePrincipal.show();*/

        } catch (Exception e) {
        }
    }
    
    public void mostrarMenuAdministrador() {
        try {
            System.out.println("holla");
            FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("cMenuAdministrador.fxml"));
            System.out.println("jjja");
            AnchorPane ventanaCuatro = (AnchorPane) loader.load();
            Stage ventana4 = new Stage();
            ventana4.setTitle("Bienvenido Administrador");
            ventana4.initOwner(stagePrincipal);
            Scene scene4 = new Scene(ventanaCuatro);
            ventana4.setScene(scene4);
            cMenuAdministradorController controller = loader.getController();
            controller.setStagePrincipal(ventana4);
            ventana4.show();

        } catch (Exception e) {
        }
    }
    
    public void mostrarPerfilAdministrador() {
        try {
           // System.out.println("holla");
            FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("cPerfilAdministrador.fxml"));
          // System.out.println("jjja");
            AnchorPane ventanaCinco = (AnchorPane) loader.load();
            Stage ventana5 = new Stage();
            ventana5.setTitle("Bienvenido Administrador");
            ventana5.initOwner(stagePrincipal);
            Scene scene5 = new Scene(ventanaCinco);
            ventana5.setScene(scene5);
            cPerfilAdministradorController controller = loader.getController();
            controller.setStagePrincipal(ventana5);
            ventana5.show();

        } catch (Exception e) {
        }
    }

    public static void main(String[] args) {
        launch(args);
    }
}

***************************************
<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane id="AnchorPane" prefHeight="350" prefWidth="320" xmlns:fx="http://javafx.com/fxml" fx:controller="pruebaventanas.VentanaPrincipalController">
    <children>
        <Label layoutX="100" layoutY="20" minWidth="120" minHeight="25" fx:id="label" text="HyperGerät Presenta"  />
        <Label layoutX="135" layoutY="45" minWidth="120" minHeight="25" fx:id="labelt" text=" TEAM"  />
        <TextField layoutX="120" layoutY="120" minWidth="100" minHeight="25" fx:id="usuario"    />
        <TextField layoutX="120" layoutY="160" minWidth="100" minHeight="25" fx:id="contrasena"    />
        <Label layoutX="50" layoutY="120" minHeight="16" minWidth="69" fx:id="label2" text="Usuario"/>
        <Label layoutX="50" layoutY="160" minHeight="16" minWidth="69" fx:id="label3" text="Contraseña"/>
        <Button layoutX="126" layoutY="235" text="Abrir Ventana" onAction="#ventanaNew" fx:id="button" />
    </children>
</AnchorPane>
********************************************************
package pruebaventanas;

import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;

public class VentanaPrincipalController implements Initializable { 

    private PruebaVentanas ProgramaPrincipal;

    @FXML
    private void ventanaNew(ActionEvent event) {
        System.out.println("Entra boton");
        validaUsuario();
        ProgramaPrincipal.mostrarMenuAdministrador();
        
    }
 
    public void setProgramaPrincipal(PruebaVentanas ProgramaPrincipal) {
        this.ProgramaPrincipal = ProgramaPrincipal;
    }

    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }
    
    private void validaUsuario(){
       
    }
}
**********************************************************************
<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.net.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane id="AnchorPane" prefHeight="350" prefWidth="320" xmlns:fx="http://javafx.com/fxml" fx:controller="pruebaventanas.cMenuTutorController">
<children>
        <Button layoutX="126" layoutY="120" text="Mi Perfil" onAction="#perfilTutor" fx:id="perfil" />
        <Button layoutX="126" layoutY="160" text="Actividades" onAction="#salirVentana" fx:id="actividades" />
        <Button layoutX="200" layoutY="280" text="Cerrar  Sesion" onAction="#salirVentana" fx:id="cerrarSesion" />
    </children>
</AnchorPane>
***********************************************************************
package pruebaventanas;

import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.stage.Stage;

public class cMenuTutorController implements Initializable {
    private Stage stagePrincipal;
    private PruebaVentanas prueba = new PruebaVentanas();
    
    public void setStagePrincipal(Stage stagePrincipal) {
        this.stagePrincipal = stagePrincipal;
    }
    
    @FXML
    private void salirVentana(ActionEvent event) {
        stagePrincipal.close();
    }
    
    @FXML
    private void perfilTutor(ActionEvent event) {
        try{
            System.out.println("Cambia Algo");
            prueba.mostrarPerfilTutor();
        }
        catch(Exception e){
            String xD = e.getMessage();
            System.out.println(xD);
        }
        
    }
    
    @FXML
    private void menuTutorAdmin(ActionEvent event) {
        try{
            System.out.println("Cambia Algo");
            prueba.mostrarPerfilTutor();
        }
        catch(Exception e){
            String xD = e.getMessage();
            System.out.println(xD);
        }
        
    }
    
    
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }    
}
**********************************************************************
<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.net.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane id="AnchorPane" prefHeight="400.0" prefWidth="600.0" styleClass="mainFxmlClass" xmlns:fx="http://javafx.com/fxml/1" fx:controller="pruebaventanas.cPerfilAdministradorController">
    <stylesheets>
        <URL value="@ventanados.css"/>
    </stylesheets>
    <children>
            <Button layoutX="25" layoutY="125" fx:id="consultar"   text="Consultar mi Informacion"  />
            <Button layoutX="25" layoutY="200" fx:id="modifica" text="Modificar Informacion"  />
            <Button layoutX="25" layoutY="300" fx:id="atras" text="⬅"  />
    </children>
</AnchorPane>
**************************************************************************
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package pruebaventanas;

import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.Initializable;
import javafx.stage.Stage;

/**
 * FXML Controller class
 *
 * @author Otoniel Aguirre
 */
public class cPerfilAdministradorController implements Initializable {

    private Stage stagePrincipal;
    
    public void setStagePrincipal(Stage stagePrincipal) {
        this.stagePrincipal = stagePrincipal;
    }
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }    
    
}
*******************************************************************
<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.net.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane id="AnchorPane" prefHeight="400.0" prefWidth="600.0" styleClass="mainFxmlClass" xmlns:fx="http://javafx.com/fxml/1" fx:controller="pruebaventanas.cPerfilTutorController">
    <stylesheets>
        <URL value="@ventanados.css"/>
    </stylesheets>
    <children>
            <Button layoutX="25" layoutY="125" fx:id="consulta"   text="Consultar mi Informacion"  />
            <Button layoutX="25" layoutY="200" fx:id="modificar" text="Modificar Informacion"  />
            <Button layoutX="25" layoutY="300" fx:id="atras" text="⬅"  />
    </children>
</AnchorPane>
*****************************************************************************

import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.Initializable;
import javafx.stage.Stage;

/**
 * FXML Controller class
 *
 * @author Otoniel Aguirre
 */
public class cPerfilTutorController implements Initializable {
    private Stage stagePrincipal;
    
    public void setStagePrincipal(Stage stagePrincipal) {
        this.stagePrincipal = stagePrincipal;
    }

    /**
     * Initializes the controller class.
     */
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }    
    
}
*****************************************************************************

El problema es que no me abre la siguiente ventana, ni me muestra nada.

Origen Enlace

Cambio de frame en javaFX

¿Como puedo cambiar de frame a otro cerrando el primer frame en javaFX? Tengo el siguiente codigo pero no funciona, no me abre las otras ventanas

package pruebaventanas;

import java.io.IOException; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Scene; import javafx.scene.layout.AnchorPane; import javafx.stage.Stage;

public class PruebaVentanas extends Application {

private Stage stagePrincipal;
private AnchorPane rootPane;

@Override
public void start(Stage stagePrincipal) throws Exception {
    this.stagePrincipal = stagePrincipal;
    mostrarVentanaPrincipal();

}

/*
 * cargamos la ventana principal
 */
public void mostrarVentanaPrincipal() {
    try {
        FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("VentanaPrincipal.fxml"));
        rootPane=(AnchorPane) loader.load();
        Scene scene = new Scene(rootPane);
        stagePrincipal.setTitle(".: TEAM :.");
        stagePrincipal.setScene(scene);
        VentanaPrincipalController controller = loader.getController();
        controller.setProgramaPrincipal(this);
        stagePrincipal.show();
    } catch (IOException e) {
    }
}

public void mostrarVentanaSecundaria() {
    try {
        FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("cMenuTutor.fxml"));
        AnchorPane ventanaDos = (AnchorPane) loader.load();
        Stage ventana2 = new Stage();
        ventana2.setTitle("Bienvenido Tutor");
        ventana2.initOwner(stagePrincipal);
        Scene scene = new Scene(ventanaDos);
        ventana2.setScene(scene);
        cMenuTutorController controller = loader.getController();
        controller.setStagePrincipal(ventana2);
        ventana2.show();

    } catch (Exception e) {
    }
}
public void mostrarPerfilTutor() {
    try {
       // System.out.println("holla");
        FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("cPerfilTutor.fxml"));
      // System.out.println("jjja");
        AnchorPane ventanaTres = (AnchorPane) loader.load();
        Stage ventana3 = new Stage();
        ventana3.setTitle("Bienvenido Tutor");
        ventana3.initOwner(stagePrincipal);
        Scene scene3 = new Scene(ventanaTres);
        ventana3.setScene(scene3);
        cPerfilTutorController controller = loader.getController();
        controller.setStagePrincipal(ventana3);
        ventana3.show();
        /**FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("VentanaPrincipal.fxml"));
        rootPane=(AnchorPane) loader.load();
        Scene scene = new Scene(rootPane);
        stagePrincipal.setTitle(".: TEAM :.");
        stagePrincipal.setScene(scene);
        VentanaPrincipalController controller = loader.getController();
        controller.setProgramaPrincipal(this);
        stagePrincipal.show();*/

    } catch (Exception e) {
    }
}

public void mostrarMenuAdministrador() {
    try {
        System.out.println("holla");
        FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("cMenuAdministrador.fxml"));
        System.out.println("jjja");
        AnchorPane ventanaCuatro = (AnchorPane) loader.load();
        Stage ventana4 = new Stage();
        ventana4.setTitle("Bienvenido Administrador");
        ventana4.initOwner(stagePrincipal);
        Scene scene4 = new Scene(ventanaCuatro);
        ventana4.setScene(scene4);
        cMenuAdministradorController controller = loader.getController();
        controller.setStagePrincipal(ventana4);
        ventana4.show();

    } catch (Exception e) {
    }
}

public void mostrarPerfilAdministrador() {
    try {
       // System.out.println("holla");
        FXMLLoader loader = new FXMLLoader(PruebaVentanas.class.getResource("cPerfilAdministrador.fxml"));
      // System.out.println("jjja");
        AnchorPane ventanaCinco = (AnchorPane) loader.load();
        Stage ventana5 = new Stage();
        ventana5.setTitle("Bienvenido Administrador");
        ventana5.initOwner(stagePrincipal);
        Scene scene5 = new Scene(ventanaCinco);
        ventana5.setScene(scene5);
        cPerfilAdministradorController controller = loader.getController();
        controller.setStagePrincipal(ventana5);
        ventana5.show();

    } catch (Exception e) {
    }
}

public static void main(String[] args) {
    launch(args);
}

}


******************************************************** package pruebaventanas;

import java.net.URL; import java.util.ResourceBundle; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.fxml.Initializable;

public class VentanaPrincipalController implements Initializable {

private PruebaVentanas ProgramaPrincipal;

@FXML
private void ventanaNew(ActionEvent event) {
    System.out.println("Entra boton");
    validaUsuario();
    ProgramaPrincipal.mostrarMenuAdministrador();
    
}

public void setProgramaPrincipal(PruebaVentanas ProgramaPrincipal) {
    this.ProgramaPrincipal = ProgramaPrincipal;
}

@Override
public void initialize(URL url, ResourceBundle rb) {
    // TODO
}

private void validaUsuario(){
   
}

}


*********************************************************************** package pruebaventanas;

import java.net.URL; import java.util.ResourceBundle; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.fxml.Initializable; import javafx.stage.Stage;

public class cMenuTutorController implements Initializable { private Stage stagePrincipal; private PruebaVentanas prueba = new PruebaVentanas();

public void setStagePrincipal(Stage stagePrincipal) {
    this.stagePrincipal = stagePrincipal;
}

@FXML
private void salirVentana(ActionEvent event) {
    stagePrincipal.close();
}

@FXML
private void perfilTutor(ActionEvent event) {
    try{
        System.out.println("Cambia Algo");
        prueba.mostrarPerfilTutor();
    }
    catch(Exception e){
        String xD = e.getMessage();
        System.out.println(xD);
    }
    
}

@FXML
private void menuTutorAdmin(ActionEvent event) {
    try{
        System.out.println("Cambia Algo");
        prueba.mostrarPerfilTutor();
    }
    catch(Exception e){
        String xD = e.getMessage();
        System.out.println(xD);
    }
    
}


@Override
public void initialize(URL url, ResourceBundle rb) {
    // TODO
}    

}


************************************************************************** /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package pruebaventanas;

import java.net.URL; import java.util.ResourceBundle; import javafx.fxml.Initializable; import javafx.stage.Stage;

/**

  • FXML Controller class

  • @author Otoniel Aguirre */ public class cPerfilAdministradorController implements Initializable {

    private Stage stagePrincipal;

    public void setStagePrincipal(Stage stagePrincipal) { this.stagePrincipal = stagePrincipal; } @Override public void initialize(URL url, ResourceBundle rb) { // TODO }

}


*****************************************************************************

import java.net.URL; import java.util.ResourceBundle; import javafx.fxml.Initializable; import javafx.stage.Stage;

/**

  • FXML Controller class

  • @author Otoniel Aguirre */ public class cPerfilTutorController implements Initializable { private Stage stagePrincipal;

    public void setStagePrincipal(Stage stagePrincipal) { this.stagePrincipal = stagePrincipal; }

    /**

    • Initializes the controller class. */ @Override public void initialize(URL url, ResourceBundle rb) { // TODO }

}


El problema es que no me abre la siguiente ventana, ni me muestra nada