Java Code Examples for javafx.scene.text.Text#setCursor()

The following examples show how to use javafx.scene.text.Text#setCursor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AboutDialog.java    From Quelea with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Create a new about dialog.
 */
public AboutDialog() {
    initModality(Modality.APPLICATION_MODAL);
    setResizable(false);
    setTitle(LabelGrabber.INSTANCE.getLabel("help.about.title"));

    BorderPane newLayout = new BorderPane();
    ImageView logo = new ImageView(new Image("file:icons/full logo.png"));
    BorderPane.setAlignment(logo, Pos.CENTER);
    newLayout.setTop(logo);

    VBox subLayout = new VBox();
    Text headingText = new Text(LabelGrabber.INSTANCE.getLabel("help.about.version") + " " + QueleaProperties.VERSION.getVersionString());
    headingText.setFont(Font.font("Arial", FontWeight.BOLD, FontPosture.REGULAR, 20));
    headingText.getStyleClass().add("text");
    subLayout.getChildren().add(headingText);
    subLayout.getChildren().add(new Text(" "));
    Text text1 = new Text(LabelGrabber.INSTANCE.getLabel("help.about.line1"));
    text1.getStyleClass().add("text");
    subLayout.getChildren().add(text1);
    Text text2 = new Text(LabelGrabber.INSTANCE.getLabel("help.about.line2"));
    text2.getStyleClass().add("text");
    subLayout.getChildren().add(text2);
    subLayout.getChildren().add(new Text(" "));
    subLayout.getChildren().add(new Label("Java: " + System.getProperty("java.version")));
    HBox debugBox = new HBox(5);
    debugBox.getChildren().add(new Label(LabelGrabber.INSTANCE.getLabel("debug.location") + ":"));
    Text debugLogText = new Text(LoggerUtils.getHandlerFileLocation());
    debugLogText.getStyleClass().add("text");
    if(Desktop.isDesktopSupported()) {
        debugLogText.setCursor(Cursor.HAND);
        debugLogText.setFill(Color.BLUE);
        debugLogText.setStyle("-fx-underline: true;");
        debugLogText.setOnMouseClicked(t -> {
            DesktopApi.open(new File(LoggerUtils.getHandlerFileLocation()));
        });
    }
    debugBox.getChildren().add(debugLogText);
    subLayout.getChildren().add(debugBox);
    Button closeButton = new Button(LabelGrabber.INSTANCE.getLabel("help.about.close"));
    closeButton.setOnAction(t -> {
        hide();
    });
    newLayout.setCenter(subLayout);
    BorderPane.setMargin(subLayout, new Insets(10));
    BorderPane.setAlignment(closeButton, Pos.CENTER);
    BorderPane.setMargin(closeButton, new Insets(10));
    newLayout.setBottom(closeButton);

    Scene scene = new Scene(newLayout);
    if (QueleaProperties.get().getUseDarkTheme()) {
        scene.getStylesheets().add("org/modena_dark.css");
    }
    setScene(scene);
}
 
Example 2
Source File: MobileServerPreference.java    From Quelea with GNU General Public License v3.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void layoutParts() {
    StackPane qrStack = new StackPane();
    qrStack.setAlignment(Pos.CENTER_LEFT);

    if (isLyrics && !getMLURL().contains(LabelGrabber.INSTANCE.getLabel("not.started.label"))) {
        ImageView qrView = new ImageView(getQRImage());
        StackPane.setAlignment(qrView, Pos.CENTER_LEFT);
        qrView.setFitHeight(100);
        qrView.setFitWidth(100);
        qrStack.getChildren().add(qrView);
        Button saveButton = new Button(LabelGrabber.INSTANCE.getLabel("save.qr.code.text"));
        StackPane.setAlignment(saveButton, Pos.CENTER_LEFT);
        saveButton.setOnAction((event) -> {
            FileChooser fileChooser = new FileChooser();
            if (QueleaProperties.get().getLastDirectory() != null) {
                fileChooser.setInitialDirectory(QueleaProperties.get().getLastDirectory());
            }
            fileChooser.getExtensionFilters().add(FileFilters.PNG);
            fileChooser.setTitle(LabelGrabber.INSTANCE.getLabel("save.qr.code.text"));
            File file = fileChooser.showSaveDialog(QueleaApp.get().getMainWindow());
            if (file != null) {
                QueleaProperties.get().setLastDirectory(file.getParentFile());
                try {
                    ImageIO.write(qrImage, "png", file);
                } catch (IOException ex) {
                    LOGGER.log(Level.WARNING, "Error saving QR file", ex);
                }
            }
        });
        saveButton.setOpacity(0);
        qrStack.setOnMouseEntered((event) -> {
            saveButton.setOpacity(0.8);
        });
        qrStack.setOnMouseExited((event) -> {
            saveButton.setOpacity(0);
        });
        qrStack.getChildren().add(saveButton);
    }

    String url = isLyrics ? getMLURL() : getRCURL();
    Text mobUrlLabel = new Text(url);
    if (Desktop.isDesktopSupported() && url.startsWith("http")) {
        mobUrlLabel.setCursor(Cursor.HAND);
        mobUrlLabel.setFill(Color.BLUE);
        mobUrlLabel.setStyle("-fx-underline: true;");
        mobUrlLabel.setOnMouseClicked((MouseEvent t) -> {
            DesktopApi.browse(url);
        });
    }

    HBox hBox = new HBox();
    hBox.setSpacing(10);
    VBox vBox = new VBox();
    vBox.setAlignment(Pos.CENTER_LEFT);
    vBox.setSpacing(10);
    vBox.getChildren().addAll(editableField, mobUrlLabel);
    hBox.getChildren().addAll(vBox, qrStack);
    HBox.setHgrow(vBox, Priority.ALWAYS);
    hBox.setAlignment(Pos.CENTER_LEFT);

    node.getChildren().addAll(hBox);

    node.setAlignment(Pos.CENTER_LEFT);
}