Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: How to make wave underline? #1225

Closed
PavelTurk opened this issue May 14, 2024 · 4 comments
Closed

Question: How to make wave underline? #1225

PavelTurk opened this issue May 14, 2024 · 4 comments

Comments

@PavelTurk
Copy link
Contributor

Could anyone say how to make wave underline? I mean something like this

Screenshot from 2024-05-14 18-05-05

@Jugen
Copy link
Collaborator

Jugen commented May 15, 2024

See the following CSS in the Wiki

-rtfx-underline-color: red;
-rtfx-underline-wave-radius: 2;
-rtfx-underline-width: 1;

@PavelTurk
Copy link
Contributor Author

@Jugen I am trying to make text waved, but something doesn't work. It seems that code doesn't react to rtfx-underline-wave-radius and -rtfx-underline-offset at all. This is my code:

public class JavaFxTest7 extends Application {

    @Override
    public void start(Stage stage) {
        CodeArea codeArea = new CodeArea("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.");
        codeArea.setWrapText(true);
        var addButton = new Button("Add");
        var removeButton = new Button("Remove");
        Scene scene = new Scene(new VBox(codeArea, addButton, removeButton), 600, 200);
        scene.getStylesheets().add(XMLEditorDemo.class.getResource("test7.css").toExternalForm());
        stage.setScene(scene);
        stage.show();

        var newStyles = new StyleSpansBuilder<Collection<String>>();
        newStyles.add(Collections.singleton("misspelled"), 5);
        codeArea.setStyleSpans(6, newStyles.create());
    }

    public static void main(String[] args) {
        launch();
    }
}

And CSS:

.misspelled {
     -rtfx-underline-color: cyan;
    -rtfx-underline-wave-radius: 2;
    -rtfx-underline-width: 1;
    -rtfx-underline-offset: 10;
}

And result:

Screenshot from 2024-05-22 12-46-00

@Jugen
Copy link
Collaborator

Jugen commented May 22, 2024

I tried your demo changing one line and it worked for me.

scene.getStylesheets().add(XMLEditorDemo.class.getResource("test7.css").toExternalForm());

Where I changed XMLEditorDemo.class to JavaFxTest7.class

@PavelTurk
Copy link
Contributor Author

@Jugen Yes, my fault, I used 0.10.9 version in my test project. The code I provided above works only with 0.11.0+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants