Example usage for javafx.scene.control Hyperlink setOnAction

List of usage examples for javafx.scene.control Hyperlink setOnAction

Introduction

In this page you can find the example usage for javafx.scene.control Hyperlink setOnAction.

Prototype

public final void setOnAction(EventHandler<ActionEvent> value) 

Source Link

Usage

From source file:mesclasses.util.NodeUtil.java

public static Hyperlink buildEleveLink(Eleve eleve, StringProperty bindingProperty, String fromView) {
    Hyperlink link = new Hyperlink();
    link.textProperty().bind(bindingProperty);
    link.setOnAction((event) -> {
        EventBusHandler.post(new OpenMenuEvent(Constants.ELEVE_RAPPORT_VIEW).setFromView(fromView));
        EventBusHandler.post(new SelectEleveEvent(eleve));
    });//from  w  w  w  .j  a v  a 2s  .  c o m
    return link;
}

From source file:Main.java

@Override
public void start(Stage stage) {
    stage.setTitle("HTML");
    stage.setWidth(500);/*from www  .j  a v  a 2  s  . com*/
    stage.setHeight(500);
    Scene scene = new Scene(new Group());
    VBox root = new VBox();
    final WebView browser = new WebView();
    final WebEngine webEngine = browser.getEngine();
    Hyperlink hpl = new Hyperlink("java2s.com");
    hpl.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent e) {
            webEngine.load("http://java2s.com");
        }
    });

    root.getChildren().addAll(hpl, browser);
    scene.setRoot(root);

    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

private void createClipList(GridPane grid) {
    final VBox vbox = new VBox(30);
    vbox.setAlignment(Pos.TOP_CENTER);//from w w  w.j  a va  2  s .c  om

    final Label clipLabel = new Label("Code Monkey To-Do List:");
    clipLabel.setId("clipLabel");

    final Button getUpButton = new Button("Get Up, Get Coffee");
    getUpButton.setPrefWidth(300);
    getUpButton.setOnAction(createPlayHandler(coffeeClip));

    final Button goToJobButton = new Button("Go to Job");
    goToJobButton.setPrefWidth(300);
    goToJobButton.setOnAction(createPlayHandler(jobClip));

    final Button meetingButton = new Button("Have Boring Meeting");
    meetingButton.setPrefWidth(300);
    meetingButton.setOnAction(createPlayHandler(meetingClip));

    final Hyperlink link = new Hyperlink("About Code Monkey...");
    link.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent event) {
            WebView wv = new WebView();
            wv.getEngine().load("http://www.jonathancoulton.com/2006/04/14/" + "thing-a-week-29-code-monkey/");

            Scene scene = new Scene(wv, 720, 480);

            Stage stage = new Stage();
            stage.setTitle("Code Monkey");
            stage.setScene(scene);
            stage.show();
        }
    });

    vbox.getChildren().addAll(clipLabel, getUpButton, goToJobButton, meetingButton, link);

    GridPane.setHalignment(vbox, HPos.CENTER);
    GridPane.setHgrow(vbox, Priority.ALWAYS);
    GridPane.setVgrow(vbox, Priority.ALWAYS);
    grid.add(vbox, 0, 0, GridPane.REMAINING, 1);
}

From source file:de.micromata.mgc.javafx.launcher.gui.AboutDialogController.java

@Override
public void initializeWithModel() {
    MgcApplicationInfo ai = model.getApplicationInfo();

    AnchorPane.setTopAnchor(aboutLogoPanel, 2.0);
    AnchorPane.setRightAnchor(aboutLogoPanel, 2.0);
    AnchorPane.setLeftAnchor(aboutLogoPanel, 2.0);
    AnchorPane.setTopAnchor(aboutLogoPanel, 2.0);
    AnchorPane.setRightAnchor(licensePanel, 2.0);
    AnchorPane.setLeftAnchor(licensePanel, 2.0);
    AnchorPane.setRightAnchor(licenceTextArea, 5.0);
    AnchorPane.setLeftAnchor(licenceTextArea, 2.0);
    //    AnchorPane.setTopAnchor(licensePanel, 100.0);
    //    AnchorPane.setBottomAnchor(configurationTabs, 5.0);
    AnchorPane.setRightAnchor(buttonPanel, 2.0);
    AnchorPane.setLeftAnchor(buttonPanel, 2.0);
    AnchorPane.setBottomAnchor(buttonPanel, 2.0);

    okButton.setOnAction(event -> getStage().close());

    String name = ai.getName() + " " + ai.getVersion();
    Text text1 = new Text(name);
    text1.setFont(Font.font("Verdana", FontWeight.BOLD, 20));
    Text text2 = new Text("\n\n" + ai.getCopyright() + "\n");
    TextFlow apptext = new TextFlow(text1, text2);
    appInfo.getChildren().add(apptext);//from  w  w w .j  av  a 2 s . com

    if (ai.getLogoLargePath() != null) {
        logo.setImage(new Image(this.getClass().getResource(ai.getLogoLargePath()).toString()));
    }

    String sdetailText = ai.getDetailInfo();
    if (StringUtils.isNotBlank(ai.getLicense()) == true) {
        sdetailText += "\n\nLicense: " + ai.getLicense();
    }
    TextFlow detailText = new TextFlow();
    detailText.getChildren().add(new Text(sdetailText));

    if (StringUtils.isNotBlank(ai.getHomeUrl()) == true) {
        detailText.getChildren().add(new Text("\n\nHomepage: "));
        Hyperlink hlink = new Hyperlink(ai.getHomeUrl());
        hlink.setOnAction(event -> SystemService.get().openUrlInBrowser(ai.getHomeUrl()));
        detailText.getChildren().add(hlink);
    }
    appDetails.getChildren().add(detailText);
    initLicenseText();
}

From source file:mesclasses.view.RapportEleveController.java

private Hyperlink buildLink(Seance seance, String suffixe) {
    String text = seance.getDateAsDate().format(Constants.LONG_DATE_FORMATTER);
    if (suffixe != null) {
        text += " " + suffixe;
    }//  w w w  .  ja v  a2  s . c o  m
    text += ", cours de " + NodeUtil.getStartTime(seance.getCours());

    Hyperlink link = new Hyperlink(text);
    link.setOnAction(e -> {
        EventBusHandler.post(new SelectSeanceEvent(seance));
        EventBusHandler.post(new OpenMenuEvent(Constants.JOURNEE_VIEW));
    });
    return link;
}

From source file:mesclasses.view.RapportEleveController.java

private void drawGrid(File file) {
    Hyperlink link = new Hyperlink(file.getName());
    link.setOnAction((event) -> openFile(file));
    int rowIndex = fileGrid.addOnNewLineIfNecessary(link, 1, HPos.LEFT);

    ComboBox<String> typeBox = new ComboBox<>();
    typeBox.getItems().addAll(Constants.FILE_TYPES);
    typeBox.getSelectionModel().select(selectedFileType.get());
    typeBox.valueProperty().addListener((observable, oldValue, newValue) -> {
        if (!newValue.equals(oldValue)) {
            try {
                EleveFileUtil.moveFileForEleve(eleve, file, newValue);
                selectFileType(newValue);
                refreshGrid();/*from   w  ww  .ja  va  2 s. c o  m*/
            } catch (IOException e) {
                ModalUtil.alert("Impossible de dplacer le fichier", e.getMessage());
            }
        }
    });
    fileGrid.add(typeBox, 2, rowIndex, null);

    Button deleteBtn = Btns.deleteBtn();
    deleteBtn.setOnAction(event -> {
        if (ModalUtil.confirm("Suppression du fichier", "Etes vous sr ?")) {
            if (file.delete()) {
                fileGrid.deleteRow(SmartGrid.row(deleteBtn));
            } else {
                ModalUtil.alert("Suppression impossible",
                        "Impossible de supprimer le fichier " + file.getName());
            }
        }
    });
    fileGrid.add(deleteBtn, 3, rowIndex, null);
}

From source file:com.bekwam.resignator.ResignatorAppMainViewController.java

@FXML
public void openJarsignerConfig() {

    clearValidationErrors();//from   w  w w  .j ava2 s  .c o  m

    if (StringUtils.isNotEmpty(activeConfiguration.getJDKHome())) {

        JarsignerConfigController jarsignerConfigView = jarsignerConfigControllerProvider.get();
        jarsignerConfigView.setParent(this);
        try {
            jarsignerConfigView.show();
        } catch (Exception exc) {
            String msg = "Error launching jarsigner config";
            logger.error(msg, exc);
            Alert alert = new Alert(Alert.AlertType.ERROR, msg);
            alert.showAndWait();
        }
    } else {
        if (logger.isDebugEnabled()) {
            logger.debug("[OPEN JARSIGNER CONFIG] JDK_HOME not set");
        }

        Alert alert = new Alert(Alert.AlertType.ERROR, "Set JDK_HOME in File > Settings");
        alert.setHeaderText("JDK_HOME not defined");

        FlowPane fp = new FlowPane();
        Label lbl = new Label("Set JDK_HOME in ");
        Hyperlink link = new Hyperlink("File > Settings");
        fp.getChildren().addAll(lbl, link);

        link.setOnAction((evt) -> {
            alert.close();
            openSettings();
        });

        alert.getDialogPane().contentProperty().set(fp);

        alert.showAndWait();
    }
}

From source file:com.bekwam.resignator.ResignatorAppMainViewController.java

private boolean validateSign() {

    if (logger.isDebugEnabled()) {
        logger.debug("[VALIDATE]");
    }/*from w w w  . j  a  va  2  s .  c om*/

    boolean isValid = true;

    //
    // Validate the Source JAR field
    //

    if (StringUtils.isBlank(activeProfile.getSourceFileFileName())) {

        if (!tfSourceFile.getStyleClass().contains("tf-validation-error")) {
            tfSourceFile.getStyleClass().add("tf-validation-error");
        }
        isValid = false;

    } else {

        if (!new File(activeProfile.getSourceFileFileName()).exists()) {

            if (!tfSourceFile.getStyleClass().contains("tf-validation-error")) {
                tfSourceFile.getStyleClass().add("tf-validation-error");
            }

            Alert alert = new Alert(Alert.AlertType.ERROR,
                    "Specified Source " + activeProfile.getArgsType() + " does not exist");

            alert.showAndWait();

            isValid = false;
        }
    }

    //
    // Validate the TargetJAR field
    //

    if (StringUtils.isBlank(activeProfile.getTargetFileFileName())) {
        if (!tfTargetFile.getStyleClass().contains("tf-validation-error")) {
            tfTargetFile.getStyleClass().add("tf-validation-error");
        }
        isValid = false;
    }

    if (activeProfile.getArgsType() == SigningArgumentsType.FOLDER) {

        if (StringUtils.equalsIgnoreCase(activeProfile.getSourceFileFileName(),
                activeProfile.getTargetFileFileName())) {

            if (!tfTargetFile.getStyleClass().contains("tf-validation-error")) {
                tfTargetFile.getStyleClass().add("tf-validation-error");
            }

            Alert alert = new Alert(Alert.AlertType.ERROR,
                    "Source folder and target folder cannot be the same");
            alert.showAndWait();

            isValid = false;
        }
    }

    //
    // #13 Validate the Jarsigner Config form
    //

    String jarsignerConfigField = "";
    String jarsignerConfigMessage = "";
    if (isValid && StringUtils.isBlank(activeProfile.getJarsignerConfigKeystore())) {
        jarsignerConfigField = "Keystore";
        jarsignerConfigMessage = "A keystore must be specified";
    } else if (isValid && StringUtils.isBlank(activeProfile.getJarsignerConfigStorepass())) {
        jarsignerConfigField = "Storepass";
        jarsignerConfigMessage = "A password for the keystore must be specified";
    } else if (isValid && StringUtils.isBlank(activeProfile.getJarsignerConfigAlias())) {
        jarsignerConfigField = "Alias";
        jarsignerConfigMessage = "An alias for the key must be specified";
    } else if (isValid && StringUtils.isBlank(activeProfile.getJarsignerConfigKeypass())) {
        jarsignerConfigField = "Keypass";
        jarsignerConfigMessage = "A password for the key must be specified";
    }

    if (StringUtils.isNotEmpty(jarsignerConfigMessage)) {

        if (logger.isDebugEnabled()) {
            logger.debug("[VALIDATE] jarsigner config not valid {}", jarsignerConfigMessage);
        }

        Alert alert = new Alert(Alert.AlertType.ERROR, "Set " + jarsignerConfigField + " in Configure");
        alert.setHeaderText(jarsignerConfigMessage);

        FlowPane fp = new FlowPane();
        Label lbl = new Label("Set " + jarsignerConfigField + " in ");
        Hyperlink link = new Hyperlink("Configure");
        fp.getChildren().addAll(lbl, link);

        link.setOnAction((evt) -> {
            alert.close();
            openJarsignerConfig();
        });

        alert.getDialogPane().contentProperty().set(fp);
        alert.showAndWait();

        isValid = false;
    }

    //
    // #38 check keystore prior to running
    //
    KeytoolCommand keytoolCommand = keytoolCommandProvider.get();

    Task<Boolean> keytoolTask = new Task<Boolean>() {
        @Override
        protected Boolean call() throws Exception {

            final List<String> aliases = keytoolCommand.findAliases(
                    activeConfiguration.getKeytoolCommand().toString(),
                    activeProfile.getJarsignerConfigKeystore(), activeProfile.getJarsignerConfigStorepass());
            if (logger.isDebugEnabled()) {
                logger.debug("[KEYTOOL] # aliases=" + CollectionUtils.size(aliases));
            }

            return true;
        }
    };
    new Thread(keytoolTask).start();

    try {
        if (!keytoolTask.get()) {
            if (logger.isDebugEnabled()) {
                logger.debug("[KEYTOOL] keystore or configuration not valid");
            }
            isValid = false;
        }
    } catch (InterruptedException | ExecutionException e) {

        isValid = false;
        logger.error("error accessing keystore", e);
        Alert alert = new Alert(Alert.AlertType.ERROR, e.getMessage() // contains formatted string
        );
        alert.showAndWait();
    }

    return isValid;
}

From source file:net.thirdy.blackmarket.controls.Dialogs.java

public static void showAbout() {
    Alert alert = new Alert(AlertType.INFORMATION);
    alert.setGraphic(new Region());
    alert.setTitle("Blackmarket " + BlackmarketApplication.VERSION);
    alert.setContentText("");
    alert.setHeaderText("");

    TextArea textArea = new TextArea("Copyright 2015 Vicente de Rivera III" + "\r\n"
            + "\r\n http://thirdy.github.io/blackmarket" + "\r\n"
            + "\r\n This program is free software; you can redistribute it and/or"
            + "\r\n modify it under the terms of the GNU General Public License"
            + "\r\n as published by the Free Software Foundation; either version 2"
            + "\r\n of the License, or (at your option) any later version." + "\r\n"
            + "\r\n This program is distributed in the hope that it will be useful,"
            + "\r\n but WITHOUT ANY WARRANTY; without even the implied warranty of"
            + "\r\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the"
            + "\r\n GNU General Public License for more details." + "\r\n"
            + "\r\n You should have received a copy of the GNU General Public License"
            + "\r\n along with this program; if not, write to the Free Software"
            + "\r\n Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA." + "\r\n");
    textArea.setEditable(false);//w w  w .  j a v a 2s  .  c  o m
    textArea.setWrapText(true);

    Hyperlink website = new Hyperlink("Visit Blackmarket Homepage");
    website.setOnAction(e -> {
        try {
            SwingUtil.openUrlViaBrowser("http://thirdy.github.io/blackmarket/");
        } catch (BlackmarketException ex) {
            logger.error(ex.getMessage(), ex);
        }
    });

    Hyperlink exwebsite = new Hyperlink("Visit Exile Tools Homepage");
    exwebsite.setOnAction(e -> {
        try {
            SwingUtil.openUrlViaBrowser("http://exiletools.com/");
        } catch (BlackmarketException ex) {
            logger.error(ex.getMessage(), ex);
        }
    });

    VBox content = new VBox(new ImageView(new Image("/images/blackmarket-logo.png")), new Label(
            "Blackmarket is fan-made software for Path of Exile but is not affiliated with Grinding Gear Games in any way."),
            new Label("A few tips:"), new Label("CTRL + Space - hot key to slide the search control pane"),
            new Label("CTRL + Enter - hot key to run the search"),
            new Label("Advance mode grants you power overwhelming of Elastic Search"),
            new Label("For more information and updates,"), website,
            new Label("Blackmarket uses Exile Tools Shop Indexer Elastic Search API:"), exwebsite,
            new Label("Comics by /u/gallio"),
            new Label("Blackmarket is 100% Free and Open Source Software under GPLv2:"), textArea);
    content.setSpacing(8);
    alert.getDialogPane().setContent(content);
    alert.showAndWait();

}

From source file:org.noroomattheinn.visibletesla.dialogs.VersionUpdater.java

public static boolean checkForNewerVersion(String thisVersion, Stage stage, final HostServices svcs,
        boolean experimentalOK) {

    final Versions versions = Versions.getVersionInfo(VersionsFile);
    if (versions == null)
        return false; // Missing, empty, or corrupt versions file

    List<Release> releases = versions.getReleases();

    if (releases != null && !releases.isEmpty()) {
        Release lastRelease = null;//from  ww  w  . j  av a2 s .  co m
        for (Release cur : releases) {
            if (cur.getInvisible())
                continue;
            if (cur.getExperimental() && !experimentalOK)
                continue;
            lastRelease = cur;
            break;
        }
        if (lastRelease == null)
            return false;
        String releaseNumber = lastRelease.getReleaseNumber();
        if (Utils.compareVersions(thisVersion, releaseNumber) < 0) {
            VBox customPane = new VBox();
            String msgText = String.format(
                    "A newer version of VisibleTesla is available:\n" + "Version: %s, Date: %tD", releaseNumber,
                    lastRelease.getReleaseDate());
            Label msg = new Label(msgText);
            Hyperlink platformLink = null;
            final URL platformURL;
            final String linkText;
            if (SystemUtils.IS_OS_MAC) {
                linkText = "Download the latest Mac version";
                platformURL = lastRelease.getMacURL();
            } else if (SystemUtils.IS_OS_WINDOWS) {
                linkText = "Download the latest Windows version";
                platformURL = lastRelease.getWindowsURL();
            } else {
                linkText = "Download the latest Generic version";
                platformURL = lastRelease.getReleaseURL();
            }
            if (platformURL != null) {
                platformLink = new Hyperlink(linkText);
                platformLink.setStyle("-fx-color: blue; -fx-text-fill: blue;");
                platformLink.setOnAction(new EventHandler<ActionEvent>() {
                    @Override
                    public void handle(ActionEvent t) {
                        svcs.showDocument(platformURL.toExternalForm());

                    }
                });
            }
            Hyperlink rnLink = new Hyperlink("Click to view the release notes");
            rnLink.setOnAction(new EventHandler<ActionEvent>() {
                @Override
                public void handle(ActionEvent t) {
                    svcs.showDocument(versions.getReleaseNotes().toExternalForm());

                }
            });
            customPane.getChildren().addAll(msg, rnLink);
            customPane.getChildren().add(platformLink);
            Dialogs.showCustomDialog(stage, customPane, "Newer Version Available", "Checking for Updates",
                    Dialogs.DialogOptions.OK, null);
            return true;
        }
    }
    return false;
}