zoukankan      html  css  js  c++  java
  • javafx分别设置四个边框

    package border;
    
    import javafx.application.Application;
    import javafx.geometry.Insets;
    import javafx.scene.Scene;
    import javafx.scene.layout.*;
    import javafx.scene.paint.Color;
    import javafx.scene.text.Text;
    import javafx.stage.Stage;
    
    public class BorderDemo extends Application {
        @Override
        public void start(Stage primaryStage) throws Exception {
    
            Text text = new Text("test");
            HBox root = new HBox();
            root.getChildren().add(text);
            root.setPadding(new Insets(50));
    //        root.setStyle("-fx-border-color: red orange black green;-fx-border- 50 40 20 10;-fx-border-style: solid dashed dotted dotted;");
    //        root.setStyle("-fx-border- 0 0 10 0;-fx-border-style: solid;-fx-border-color: red");
    
            BorderStroke borderStroke = new BorderStroke(null,null, Color.BLACK,null, null,null,BorderStrokeStyle.SOLID,null,null, BorderWidths.DEFAULT,new Insets(50));
    
            root.setBorder(new Border(borderStroke));
    
            Scene scene = new Scene(root, 500, 300);
    
            primaryStage.setScene(scene);
    
            primaryStage.show();
    
        }
    
        public static void main(String[] args) {
            launch(args);
        }
    }
    
    

    效果图

    如果把style中的空格改为逗号,即root.setStyle("-fx-border-color: red,orange,black,green;...")

    效果图

    看下官方文档,如果四个边框分开设置,就是要用逗号,实际却是用空格隔开

    -fx-border-color

    A series of paint values or sets of four paint values, separated by commas. For each item in the series, if a single paint value is specified, then that paint is used as the border for all sides of the region; and if a set of four paints is specified, they are used for the top, right, bottom, and left borders of the region, in that order. If the border is not rectangular, only the first paint value in the set is used.

  • 相关阅读:
    .Net Core 静态文件跨域访问
    SQL Server查看锁表与解锁表
    C# 获取Bilibili网站中的视频信息
    C# 生成条形码、二维码
    HttpWebRequest 远程服务器返回错误: (403) 已禁止
    C# NPOI导出Excel以及动态设置列宽
    【c++设计模式】观察者模式
    【c++设计模式】状态模式
    【c++设计模式】职责链模式
    【c++设计模式】命令模式
  • 原文地址:https://www.cnblogs.com/mlr-wjy/p/12843695.html
Copyright © 2011-2022 走看看