package class10_2_JavaFXMLMultipleWindows_start;// Dr. Yoder. MSOE. 05 January 2017 import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.scene.control.Label; import javafx.stage.Stage; import javax.swing.*; import java.io.IOException; public class MainController { @FXML private Label longLabel; private SecondWindowController secondWindowController; public Label getLongLabel() { return longLabel; } /** * Handler for the show window button * @param actionEvent ignored */ @FXML public void handleShowWindow(ActionEvent actionEvent) { if(secondWindowController == null) { Stage secondaryStage = new Stage(); try { Parent root = FXMLLoader.load( getClass().getResource("secondWindow.fxml")); secondaryStage.setTitle("Second Window"); secondaryStage.setScene(new Scene(root,400,300)); secondaryStage.show(); } catch (IOException e) { JOptionPane.showMessageDialog( null,"Could not load second window."); // TODO: Use Alerts instead } } } }