【问题标题】:How to get rid of white border around JavaFX Textview如何摆脱 JavaFX Textview 周围的白色边框
【发布时间】:2015-08-12 20:46:17
【问题描述】:

我的 TextArea 周围有一个我无法摆脱的白色边框

代码如下:

    textArea = new TextArea();
    textArea.getStyleClass().add("textArea");
    textArea.setWrapText(true);

还有css:

.textArea{
-fx-background-insets: 0 0 0 0, 0, 1, 2;
-fx-background-radius: 0;
-fx-text-fill: white;
-fx-border-color: #2a2a2a;
-fx-border-width: 0;}

.textArea .content{
    -fx-background-color: #2a2a2a;
    -fx-border-color: #2a2a2a;
}

谁能帮忙?

【问题讨论】:

    标签: css javafx javafx-2 javafx-8 javafx-css


    【解决方案1】:

    这适用于我的测试用例:

    .text-area, .text-area .content {
        -fx-background-color: #2a2a2a ;
        -fx-background-radius: 0 ;
    }
    .text-area {
        -fx-text-fill: white ;
    }
    

    测试代码:

    import javafx.application.Application;
    import javafx.geometry.Insets;
    import javafx.scene.Scene;
    import javafx.scene.control.TextArea;
    import javafx.scene.layout.BorderPane;
    import javafx.stage.Stage;
    
    public class TextAreaBorderTest extends Application {
    
        @Override
        public void start(Stage primaryStage) {
            TextArea textArea = new TextArea();
            BorderPane root = new BorderPane(textArea);
            root.setPadding(new Insets(24));
            Scene scene = new Scene(root);
            scene.getStylesheets().add("text-area-border-test.css");
            primaryStage.setScene(scene);
            primaryStage.show();
        }
    
        public static void main(String[] args) {
            launch(args);
        }
    }
    

    我加了

    .root {
        -fx-background-color: black ;
    }
    

    到 CSS 以进行测试。

    【讨论】:

    • .text-area, .text-area .content 造成了影响
    猜你喜欢
    • 1970-01-01
    • 2013-03-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多