如何在 JavaFX 的手风琴中的 TitledPanes 之间添加填充 [英] How to add padding between TitledPanes in an Accordion in JavaFX

查看:41
本文介绍了如何在 JavaFX 的手风琴中的 TitledPanes 之间添加填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 Accordion 中的 TitledPane 之间添加填充(Accordion 中的间距).

问题在于,当一个 TitledPane 被展开时,下一个 TitledPane 的外观和感觉会被破坏.

TitledPane未展开

一个 TitledPane 展开

我使用了以下 CSS:

.titled-pane {-fx-skin: "com.sun.javafx.scene.control.skin.TitledPaneSkin";-fx-text-fill: -fx-text-base-color;-fx 填充:0.5em;}

一张图显示了两个 TitledPane 未展开时的分离,另一张图显示了打开第一个 TitledPane 后第二个 TitledPane 的外观.

解决方案

这是一个错误(我创建了一个错误报告:

I would like to add padding between TitledPanes in an Accordion (spacing in Accordion).

The problem is that, when a TitledPane is expanded, the look and feel of the next TitledPane is broken.

TitledPanes unexpanded

One TitledPane expanded

I have used the following CSS:

.titled-pane {
    -fx-skin: "com.sun.javafx.scene.control.skin.TitledPaneSkin";    
    -fx-text-fill: -fx-text-base-color;
    -fx-padding: 0.5em;
}

One image show the separation between 2 TitledPanes unexpanded, and another image show the look an feel of the second TitledPane after open the first one.

解决方案

It's a bug (I've created a bug report: JDK-8162599).

As a workaround, if you specify only the bottom padding of TitledPanes (rather than the top), the spacing between TitledPanes in the Accordion is correct.

CSS to add bottom padding

.accordion > .titled-pane {
    -fx-padding: 0 0 0.5em 0;
}

An example Accordion looks like this:

这篇关于如何在 JavaFX 的手风琴中的 TitledPanes 之间添加填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆