javafx怎么隐藏一个pane_在JavaFX 2.2中隐藏TitledPane的标题

A TitledPane features a title. Here is how a couple of them can look:

The titles are "More..", "Smileys" and "Send". I want to completely hide the Send title, not just remove the text "Send". The end result should be something like this:

Is it possible?

解决方案

I would just use a standard Pane for the third content area rather than a TitledPane and apply the relevant styles to trick JavaFX into styling the bottom panel as if it was the content area of a TitlePane.

Roughly speaking you will require some FXML markup similar to this:

xmlns:fx="http://javafx.com/fxml/1"

xmlns="http://javafx.com/javafx/2.2" >

minWidth="0.0"

prefHeight="180.0"

prefWidth="200.0" />

minHeight="0.0"

minWidth="0.0"

prefHeight="180.0"

prefWidth="200.0" />

layoutY="21.0"

mnemonicParsing="false"

text="Button" />

This basically lays the three panes out in a VBox so that they stack correctly and applies some styles to tell JavaFX how to render the third Pane.

In order to achieve the correct look of the third Pane you will need to give it a style class of "content". This is the name of the background Pane that is part of the TitledPanes sub-structure and tells JavaFX to render the pane in the same way as the TitledPane control.

This will not work as it stands though as the actual css definition looks something like this:

.titled-pane .content { // styles defined here }

What this means is that the style will only apply to nodes that have a style class of "content" if they are also inside a node with a style class of "titled-pane".

The simple way to fix this is to give the root container Pane (the VBox in this case) a style class of "titled-pane", effectively tricking JavaFX into thinking the third pane is a titledPanes content area.

The output of this is shown below:

and with both TitledPanes collapsed:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值