Blurred text in JavaFX TextArea


I am having a weird issue with JavaFX. I designed a simple Scene in SceneBuilder. The text looks ok in a preview, but in the running the app the text looks blurred, consider the following image. example Here is the FXML:

<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.paint.*?>

<AnchorPane id="AnchorPane" fx:id="root" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns:fx="" xmlns="" fx:controller="br.mviccari.javafxtest.controllers.TelaMensagemController">
    <TitledPane alignment="CENTER_LEFT" animated="false" collapsible="false" contentDisplay="LEFT" prefHeight="400.0" prefWidth="600.0" text="Janela legal" textAlignment="LEFT" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
        <AnchorPane id="Content" minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
            <HBox id="HBox" alignment="CENTER" spacing="5.0" AnchorPane.bottomAnchor="14.0" AnchorPane.rightAnchor="14.0">
                <Button mnemonicParsing="false" onAction="#acaoFodase" prefHeight="53.9609375" prefWidth="128.0" text="Foda-se" />
                <Button mnemonicParsing="false" onAction="#acaoOk" prefHeight="53.9609375" prefWidth="128.0" text="OK" />
            <TextArea fx:id="campoTexto" disable="false" editable="true" focusTraversable="true" prefHeight="278.0" prefWidth="570.0" rotate="0.0" text="Aqui vai um texto padrĂ£o motherfucker!" wrapText="true" AnchorPane.bottomAnchor="82.0" AnchorPane.leftAnchor="14.0" AnchorPane.rightAnchor="12.0" AnchorPane.topAnchor="14.0" />

And here is the application class code:

FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/br/mviccari/javafxtest/layouts/telaMensagem.fxml"));
Parent root = fxmlLoader.load();
TelaMensagemController controller = fxmlLoader.getController();
controller.setParametroDeTeste("PIKACHU EU ESCOLHO VC!");
Stage stage = new Stage(StageStyle.DECORATED);
stage.setTitle("My New Stage Title");
stage.setScene(new Scene(root, 450, 450));

I have tried to run the app using JDK 7, this way the text is not blurred anymore, but how can I run it with JDK 8 showing a normal text

I have put my project on bitbucket, if anyone tries to see the code or checkout to your machine, you can see this on your own

4/23/2018 5:18:45 AM

Accepted Answer

I have figured out a solution for this issue. I was able to ascertain that the issue is centered around a bug introduced in JavaFX 8 which causes some blurriness of the content displayed within a ScrollPane when said ScrollPane has decimal value constraints, the bug has to do with the cached image of the content so turning off caching works. TextAreas make use of ScrollPanes.

ScrollPane sp = (ScrollPane)textArea.getChildrenUnmodifiable().get(0);
for (Node n : sp.getChildrenUnmodifiable()) {
7/25/2015 3:38:10 AM

If someone has a similar problem inside PopOver from ControlsFX: Blurred text inside text controls (WebView, TextArea, etc).

The solution is to override the -fx-stroke-width attribute inside the .popover > .border selector:

.popover > .border { -fx-stroke-width: 1; }


val popOver = PopOver()
val webView = WebView()
webView.engine.loadContent("<html>Some text that should be not blurred</html>")
popOver.contentNode = webView

var b = Button("Press")
val scene = Scene(StackPane(b), 800.0, 600.0)

b.onAction = EventHandler { }

primaryStage.scene = scene

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow