JavaFX TextArea隐藏滚动条 [英] JavaFX TextArea Hiding Scroll Bars
本文介绍了JavaFX TextArea隐藏滚动条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个TextArea(),想隐藏垂直/水平滚动条.我看到该控件似乎具有一个内置的滚动窗格,可以根据需要显示.
I have a TextArea() and would like to hide the vertical/horizontal scroll bars. I see that the control seems to have a built in scroll-pane that shows as needed.
TextArea numberPane = new TextArea();
numberPane.setEditable(false);
numberPane.setMaxWidth( 75 );
// Set the characteristics of our line number pane
numberPane.setId( "line-number-pane" );
在我的CSS文件中,我具有以下设置.
In my CSS file I have the follow settings.
#line-number-pane
{
-fx-text-fill: white;
-fx-background-color: black;
-fx-font: 12px "Courier New";
-fx-font-family: "Courier New";
-fx-font-weight: bold;
}
#line-number-pane .scroll-pane
{
-fx-hbar-policy : never;
-fx-vbar-policy : never;
}
与预期的一样,文本区域的字体/颜色/大小也可以正常工作.但是,滚动窗格策略似乎无效.
As expected the text area font/color/size works just fine. However, the scroll-pane policy doesn't seem to work.
我应该能够通过CSS文件隐藏滚动条,还是有一些代码可以解决这个问题.
Should I be able to hide the scroll bars via the CSS file or is there some code that will do the trick.
谢谢.
推荐答案
textArea.setWrapText(true);
删除垂直滚动条
ScrollBar scrollBarv = (ScrollBar)ta.lookup(".scroll-bar:vertical");
scrollBarv.setDisable(true);
CSS
.text-area .scroll-bar:vertical:disabled {
-fx-opacity: 0;
}
这篇关于JavaFX TextArea隐藏滚动条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文