Example usage for javafx.fxml FXMLLoader load

List of usage examples for javafx.fxml FXMLLoader load

Introduction

In this page you can find the example usage for javafx.fxml FXMLLoader load.

Prototype

public static <T> T load(URL location) throws IOException 

Source Link

Document

Loads an object hierarchy from a FXML document.

Usage

From source file:com.toyota.carservice.SplashScreen.java

@Override
public void start(Stage stage) throws Exception {
    Parent root = FXMLLoader.load(getClass().getResource("/com/toyota/carservice/view/formSplash.fxml"));
    Scene scene = new Scene(root);
    stage.setTitle("Connection to database...");
    ApplicationContext appContex = config.getInstance().getApplicationContext();
    Resource resource = appContex.getResource("classpath:com/toyota/carservice/img/kallatoyota.png");
    stage.getIcons().add(new Image(resource.getURI().toString()));
    stage.setScene(scene);/*from   w ww  . j a  v a 2s .c o m*/
    stage.initStyle(StageStyle.UNDECORATED);
    stage.show();
}

From source file:nobelprize.NobelPrize.java

@Override
public void start(Stage stage) throws Exception {
    Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));

    Scene scene = new Scene(root);

    stage.setScene(scene);//from   w w  w . j ava  2  s .co m
    stage.show();
}

From source file:com.ti.msp430.usb.hiddemo.JavaUSBFXMain.java

@Override
public void start(Stage primaryStage) throws Exception {

    Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));

    // StackPane root = new StackPane();
    // root.getChildren().add(btn);

    Scene scene = new Scene(root, 1000, 700);

    primaryStage.setTitle("HID Datapipe USB");
    primaryStage.setScene(scene);/*from  w w  w.ja v a 2 s  .co m*/
    primaryStage.show();

}

From source file:fx.browser.Window.java

public void setLocation(String location) throws URISyntaxException {
    System.out.println("# " + this.toString() + "-Classloader: " + getClass().getClassLoader().toString()
            + " setLocation()");
    this.location = location;
    HttpGet httpGet = new HttpGet(new URI(location));

    try (CloseableHttpResponse response = Browser.getHttpClient().execute(httpGet)) {
        switch (response.getStatusLine().getStatusCode()) {

        case HttpStatus.SC_OK:
            FXMLLoader loader = new FXMLLoader();
            Header header = response.getFirstHeader("class-loader-url");

            if (header != null) {
                URL url = new URL(location);

                url = new URL(url.getProtocol(), url.getHost(), url.getPort(), header.getValue());
                if (logger.isLoggable(Level.INFO)) {
                    logger.log(Level.INFO, "Set up remote classloader: {0}", url);
                }//w  w  w  .  j  ava  2  s .  co  m

                loader.setClassLoader(HttpClassLoader.getInstance(url, getClass().getClassLoader()));
            }

            try {
                ByteArrayOutputStream buffer = new ByteArrayOutputStream();

                response.getEntity().writeTo(buffer);
                response.close();
                setContent(loader.load(new ByteArrayInputStream(buffer.toByteArray())));
            } catch (Exception e) {
                response.close();
                logger.log(Level.INFO, e.toString(), e);
                Node node = loader.load(getClass().getResourceAsStream("/fxml/webview.fxml"));
                WebViewController controller = (WebViewController) loader.getController();

                controller.view(location);
                setContent(node);
            }

            break;

        case HttpStatus.SC_UNAUTHORIZED:
            response.close();
            Optional<Pair<String, String>> result = new LoginDialog().showAndWait();

            if (result.isPresent()) {
                URL url = new URL(location);

                Browser.getCredentialsProvider().setCredentials(new AuthScope(url.getHost(), url.getPort()),
                        new UsernamePasswordCredentials(result.get().getKey(), result.get().getValue()));
                setLocation(location);
            }

            break;
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:ipat_fx.IPAT_FX.java

@Override
public void start(Stage stage) throws Exception {
    String contextPath = System.getProperty("user.dir") + "/web/";
    File logFile = new File(contextPath + "/log/log4j-IPAT.log");
    System.setProperty("rootPath", logFile.getAbsolutePath());

    Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));
    Scene scene = new Scene(root);
    stage.setScene(scene);//from w  w w  . j  av a2  s .c  o  m
    stage.show();
    stage.setOnHiding((WindowEvent event) -> {
        Platform.runLater(() -> {
            File src = new File(contextPath + "/Client Data");
            DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
            Date date = new Date();
            File dest = new File(contextPath + "/Saves/Ipat_" + dateFormat.format(date));
            if (!dest.exists()) {
                dest.mkdirs();
            }
            try {
                FileUtils.copyDirectory(src, dest);
            } catch (IOException ex) {
                Logger.getLogger(IPAT_FX.class.getName()).log(Level.SEVERE, null, ex);
            }
            System.exit(0);
        });
    });
}

From source file:memoryaid.GalleryController.java

@FXML
private void HandleGalleryLinkAction(ActionEvent event) throws IOException {
    System.out.println("You clicked me!");
    Parent Gallery = FXMLLoader.load(getClass().getResource("FamilySpecHome.fxml"));
    Scene Gallery_scene = new Scene(Gallery);
    Stage app_stage = (Stage) ((Node) event.getSource()).getScene().getWindow();
    app_stage.hide();/*  w w w. j a v a2  s  .  c om*/
    app_stage.setScene(Gallery_scene);
    app_stage.show();
}

From source file:webapptest.LogInScreenController.java

@FXML
public void logInPressed(ActionEvent event) throws IOException {
    int response = passwordVerification();

    if (response == 1) {
        Stage stageTheLabelBelongs = (Stage) ((Node) event.getSource()).getScene().getWindow();

        Parent webapp = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));

        Scene scene = new Scene(webapp);

        stageTheLabelBelongs.setScene(scene);
        stageTheLabelBelongs.show();/* ww w  .  j av  a 2  s.com*/
    }
}

From source file:de.thomasbolz.renamer.Main.java

@Override
public void start(Stage primaryStage) throws Exception {
    Parent root = FXMLLoader.load(getClass().getResource("/de/thomasbolz/renamer/renamer.fxml"));
    final Properties properties = readPropertiesFromClasspath("renamer.properties");
    primaryStage.setTitle(properties.getProperty("app.name", "app.name") + " v"
            + properties.getProperty("app.version", "app.version"));
    primaryStage.setScene(new Scene(root, 1000, 800));
    primaryStage.getIcons().add(new Image("icon-16.png"));
    primaryStage.getIcons().add(new Image("icon-32.png"));
    primaryStage.getIcons().add(new Image("icon-64.png"));
    primaryStage.getIcons().add(new Image("icon-128.png"));
    primaryStage.getIcons().add(new Image("icon-256.png"));
    primaryStage.show();//from   w  w  w.ja v a 2s  . co m
}

From source file:com.exalttech.trex.ui.UIBaseTest.java

@Override
public void start(Stage stage) throws Exception {
    TrexApp.setPrimaryStage(stage);//ww  w  . j a  v  a2s  .  c o m
    AnchorPane page = (AnchorPane) FXMLLoader.load(getClass().getResource("/fxml/MainView.fxml"));
    Scene scene = new Scene(page);
    scene.getStylesheets().add(TrexApp.class.getResource("/styles/mainStyle.css").toExternalForm());
    stage.setScene(scene);
    stage.setTitle("TRex");
    stage.setResizable(true);
    stage.setMinWidth(1100);
    stage.setMinHeight(670);
    stage.show();
}

From source file:org.pdfsam.configuration.PdfsamEnterpriseConfig.java

@Bean(name = "logo")
public Group logo() throws IOException {
    Resource resource = new ClassPathResource("/fxml/LogoEnterprise.fxml");
    return FXMLLoader.load(resource.getURL());
}