JAVAFX窗口设置阴影效果

        DropShadow dropshadow = new DropShadow();// 阴影向外
        dropshadow.setRadius(10);// 颜色蔓延的距离
        dropshadow.setOffsetX(0);// 水平方向,0则向左右两侧,正则向右,负则向左
        dropshadow.setOffsetY(0);// 垂直方向,0则向上下两侧,正则向下,负则向上
        dropshadow.setSpread(0.1);// 颜色变淡的程度
        dropshadow.setColor(Color.BLACK);// 设置颜色
        root.setEffect(dropshadow);// 绑定指定窗口控件
        HBox treeRoot = new HBox();// 创建最底层的面板
        treeRoot.setBackground(Background.EMPTY);// 设置背景色为透明
        treeRoot.setAlignment(Pos.CENTER);// 设置对齐方式为居中
        treeRoot.setPadding(new Insets(dropshadow.getRadius()));// 设置要显示的阴影宽度为根控件与底层容器的四边距离
        treeRoot.getChildren().add(root);// 添加根控件到底层容器中
        root.setPrefSize(270, 350);
        Scene scene = new Scene(treeRoot, 270, 350, Color.TRANSPARENT);
        primaryStage.initStyle(StageStyle.TRANSPARENT);// 设定窗口无边框

 

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值