gpt4 book ai didi

JavaFx:文本溢出:省略号类似物

转载 作者:行者123 更新时间:2023-12-01 11:27:37 24 4
gpt4 key购买 nike

我有一个选项卡 Pane ,我希望所有选项卡标题具有相同的宽度。所以我这样做了:

.tab-header-area .tab{
-fx-min-width:200;
-fx-pref-width:200;
-fx-max-width:200;
}

问题是,如果文本长于其空间,则标签会与关闭按钮混淆。如何让 .tab > .tab-container > .tab-label 剪切文本并在末尾添加“...”?

最佳答案

代码选项:

TabPane pane = new TabPane();
pane.setTabMinWidth(200);
pane.setTabMaxWidth(200);

CSS 选项

.tab-pane{
-fx-tab-min-width:200;
-fx-tab-max-width:200;
}

enter image description here

旧解决方案:

You have to set -fx-max-width for .tab > .tab-container > .tab-label There are 2 options:

1) Set the default sizes for label and not tab (selected tab will be a little bit larger with x button in it):

.tab-pane > .tab-header-area > .headers-region > .tab > .tab-container > .tab-label {
-fx-min-width:200;
-fx-pref-width:200;
-fx-max-width:200;
}

2) Use your css and some smaller value for labels(This way all tabs will be always 200 px):

.tab-header-area .tab{
-fx-min-width:200;
-fx-pref-width:200;
-fx-max-width:200;
}

.tab-pane > .tab-header-area > .headers-region > .tab > .tab-container > .tab-label {
-fx-min-width:175;
-fx-pref-width:175;
-fx-max-width:175;
}

关于JavaFx:文本溢出:省略号类似物,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30692131/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com