Dinámicamente cambiar el tamaño de la fuente y su estilo en el TextArea provoca errores de relleno

a.2.c.4:

Estoy creando un pequeño editor de texto con JavaFX.

Para este propósito utilizo TextArea y ComboBox'es a dinámicamente estilo que: por ejemplo, cambiar el tipo de letra, su tamaño, por lo que es negrita, cursiva y así sucesivamente. Que tipo de obras, sin embargo hay un error visual inquietante que no puedo aguantar.

Traté de reducir el problema y aquí es un código más simple que tiene el mismo comportamiento y un par de fotos para entender lo que estoy hablando:

(A reproducir el error establecer el tamaño a 70 luego elija audaz y verá cómo los pasos de texto de distancia desde el borde).

public class Main extends Application {
    public void start(Stage stage) {
        textArea = new TextArea("TEST 112123");
        textArea.setPrefWidth(800);
        textArea.setPrefHeight(400);
        textArea.setLayoutY(40);

        CheckBox bold = new CheckBox("BOLD");
        bold.setLayoutX(20);
        bold.setOnAction(e -> {
            Font currentFont = textArea.getFont();

            if (bold.isSelected()) {
                textArea.setFont(
                        new Font("System Bold", currentFont.getSize()));
        //I set new Font each time to save all of it's past properties and
        //change only one of them, this is the only way that I found to do 
        //this as there are no setters in the Font class, only constructors

            } else {
                textArea.setFont(
                        new Font("System", currentFont.getSize()));
            }
        });

        ComboBox sizeBox = new ComboBox();
        //I removed the list of options and the input validity check
        sizeBox.setLayoutX(80);
        sizeBox.setEditable(true);
        sizeBox.setOnAction(e -> {
            textArea.setFont(new Font(textArea.getFont().getName(),
                           Double.valueOf((String)sizeBox.getValue())));
        });

        stage.setScene(new Scene(new Group(textArea, bold, sizeBox), 800, 500));
        stage.show();
    }
}

imágenes: https://imgur.com/a/Cg53nAL

repollo:

Usted puede agregar la siguiente hoja de estilo.

.text-area .content {
    -fx-padding: 3 7 3 7;
}

Se anula el relleno de modena.css:

.text-area .content {
    /*the is 1px less top and bottom than TextInput because of scrollpane border */
    -fx-padding: 0.25em 0.583em 0.25em 0.583em; /* 3 7 3 7 */
    -fx-cursor: text;
    -fx-background-color:
        linear-gradient(from 0px 0px to 0px 4px, derive(-fx-control-inner-background, -8%), -fx-control-inner-background);
    -fx-background-radius: 2;
}

Supongo que te gusta

Origin http://43.154.161.224:23101/article/api/json?id=215283&siteId=1
Recomendado
Clasificación