Search in sources :

Example 46 with FXMLLoader

use of javafx.fxml.FXMLLoader in project bitsquare by bitsquare.

the class FxmlViewLoader method loadFromFxml.

private View loadFromFxml(URL fxmlUrl) {
    checkNotNull(fxmlUrl, "FXML URL must not be null");
    try {
        FXMLLoader loader = new FXMLLoader(fxmlUrl, resourceBundle);
        loader.setControllerFactory(viewFactory);
        loader.load();
        Object controller = loader.getController();
        if (controller == null)
            throw new ViewfxException("Failed to load view from FXML file at [%s]. " + "Does it declare an fx:controller attribute?", fxmlUrl);
        if (!(controller instanceof View))
            throw new ViewfxException("Controller of type [%s] loaded from FXML file at [%s] " + "does not implement [%s] as expected.", controller.getClass(), fxmlUrl, View.class);
        return (View) controller;
    } catch (IOException ex) {
        throw new ViewfxException(ex, "Failed to load view from FXML file at [%s]", fxmlUrl);
    }
}
Also used : ViewfxException(io.bitsquare.gui.common.ViewfxException) IOException(java.io.IOException) FXMLLoader(javafx.fxml.FXMLLoader) View(io.bitsquare.gui.common.view.View) FxmlView(io.bitsquare.gui.common.view.FxmlView)

Example 47 with FXMLLoader

use of javafx.fxml.FXMLLoader in project PretendYoureXyzzyReborn by devgianlu.

the class GameCell method updateItem.

@Override
protected void updateItem(CGame item, boolean empty) {
    super.updateItem(item, empty);
    if (empty) {
        setGraphic(null);
    } else {
        FXMLLoader loader = new FXMLLoader(getClass().getResource("GameCell.fxml"));
        loader.setController(new Controller(item));
        try {
            setGraphic(loader.load());
        } catch (IOException ex) {
            throw new RuntimeException(ex);
        }
    }
}
Also used : IOException(java.io.IOException) FXMLLoader(javafx.fxml.FXMLLoader)

Example 48 with FXMLLoader

use of javafx.fxml.FXMLLoader in project PretendYoureXyzzyReborn by devgianlu.

the class PlayerCell method updateItem.

@Override
protected void updateItem(CPlayer item, boolean empty) {
    super.updateItem(item, empty);
    if (empty) {
        setGraphic(null);
    } else {
        FXMLLoader loader = new FXMLLoader(getClass().getResource("PlayerCell.fxml"));
        loader.setController(new Controller(item));
        try {
            setGraphic(loader.load());
        } catch (IOException ex) {
            throw new RuntimeException(ex);
        }
    }
}
Also used : IOException(java.io.IOException) FXMLLoader(javafx.fxml.FXMLLoader)

Example 49 with FXMLLoader

use of javafx.fxml.FXMLLoader in project PretendYoureXyzzyReborn by devgianlu.

the class UIClient method loadScene.

public static <T> void loadScene(@Nullable Stage stage, String title, String layout, @NotNull T controller) {
    FXMLLoader loader = new FXMLLoader(controller.getClass().getResource(layout));
    loader.setController(controller);
    try {
        Parent root = loader.load();
        if (stage == null)
            stage = new Stage();
        stage.setTitle(title);
        stage.setScene(new Scene(root));
        stage.show();
    } catch (IOException ex) {
        throw new RuntimeException(ex);
    }
}
Also used : Parent(javafx.scene.Parent) Stage(javafx.stage.Stage) IOException(java.io.IOException) Scene(javafx.scene.Scene) FXMLLoader(javafx.fxml.FXMLLoader)

Example 50 with FXMLLoader

use of javafx.fxml.FXMLLoader in project arquivoProject by fader-azevedo.

the class CriarPautaController method scan.

@FXML
private void scan() throws IOException, DocumentException {
    int numPDF = 20;
    PdfReader[] pdfArray = new PdfReader[numPDF];
    DBConnector gerrarPDF = new DBConnector(pdfArray);
    Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
    alert.setTitle("Por favor confirma");
    alert.setHeaderText("Desejas Scannear mais uma pagina dessa Pauta?");
    alert.setContentText("Caso sim, põe a página no scan!");
    ((Button) alert.getDialogPane().lookupButton(ButtonType.OK)).setText("Sim");
    ((Button) alert.getDialogPane().lookupButton(ButtonType.CANCEL)).setText("Não");
    // array que vai possibilitar a remocao de pdf
    String[] arrayFiles = new String[numPDF];
    // array que vai possibilitar a remocao de pdf
    int index = 0;
    do {
        Imaging imaging = new Imaging("myApp", 0);
        Result result = imaging.scan(Request.fromJson("{" + "\"output_settings\" : [ {" + "  \"type\" : \"save\"," + "  \"format\" : \"pdf\"," + "  \"save_path\" : \"documentos/pautas\\\\${TMS}${EXT}\"" + "} ]" + "}"), "select", false, false);
        // salva o doc
        if (result == null) {
            return;
        }
        // formatcao do caminho
        String url = result.getPdfFile().getPath().replace("\\", "/");
        // busca o doc que acaba de ser guardado
        PdfReader pdf = new PdfReader(url);
        // preeche o array com a foto salva
        gerrarPDF.preecherArrayPDF(pdf);
        arrayFiles[index] = url;
        index++;
    } while (alert.showAndWait().get() == javafx.scene.control.ButtonType.OK);
    iconCheck.setVisible(true);
    btnScan.setDisable(true);
    Calendar cal = Calendar.getInstance();
    pdfNome = "pauta_" + new SimpleDateFormat("yyyy-MM-dd-HH-mm").format(cal.getTime());
    String pdfCaminho = gerrarPDF.gerrarPDFPauta(pdfNome);
    /*ciclo de remocao*/
    for (String arrayFile : arrayFiles) {
        if (arrayFile != null) {
            File f = new File(arrayFile);
            f.delete();
        }
    }
    FXMLLoader loader = new FXMLLoader();
    loader.load(getClass().getResource("/view/PdfViewer.fxml").openStream());
    Parent parent = loader.getRoot();
    PdfViewerController pdfController = loader.getController();
    pdfController.initialize();
    pdfController.loadFile(pdfCaminho);
    final Stage dialog = new Stage();
    dialog.initModality(Modality.APPLICATION_MODAL);
    Scene dialogScene = new Scene(parent, 500, 620);
    dialog.setScene(dialogScene);
    dialog.setTitle("Resultado de Scan");
    dialog.setResizable(false);
    dialog.show();
}
Also used : Parent(javafx.scene.Parent) Calendar(java.util.Calendar) PdfReader(com.lowagie.text.pdf.PdfReader) Scene(javafx.scene.Scene) FXMLLoader(javafx.fxml.FXMLLoader) Result(com.asprise.imaging.core.Result) Button(javafx.scene.control.Button) JFXButton(com.jfoenix.controls.JFXButton) Imaging(com.asprise.imaging.core.Imaging) Stage(javafx.stage.Stage) Alert(javafx.scene.control.Alert) SimpleDateFormat(java.text.SimpleDateFormat) File(java.io.File) FXML(javafx.fxml.FXML)

Aggregations

FXMLLoader (javafx.fxml.FXMLLoader)113 IOException (java.io.IOException)67 Scene (javafx.scene.Scene)37 Parent (javafx.scene.Parent)33 Stage (javafx.stage.Stage)28 URL (java.net.URL)24 FXML (javafx.fxml.FXML)24 Pane (javafx.scene.layout.Pane)24 ActionEvent (javafx.event.ActionEvent)18 AnchorPane (javafx.scene.layout.AnchorPane)18 ResourceBundle (java.util.ResourceBundle)16 BorderPane (javafx.scene.layout.BorderPane)16 Initializable (javafx.fxml.Initializable)14 JFXButton (com.jfoenix.controls.JFXButton)13 StackPane (javafx.scene.layout.StackPane)13 KeyFrame (javafx.animation.KeyFrame)12 Timeline (javafx.animation.Timeline)12 Duration (javafx.util.Duration)12 Level (java.util.logging.Level)11 Logger (java.util.logging.Logger)11