本文介绍了如何删除JavaFX按钮的默认边框发光(选中时)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试删除选中JavaFX按钮时默认显示的边框发光(请参见下面的屏幕截图):

I'm trying to remove the border glow (please see screenshot below) that appears by default when a JavaFX button is selected:

我也想使用CSS执行此操作,而不是在主JavaFX脚本中以声明方式执行此操作。但是,我无法弄清楚我需要使用什么CSS属性(呃,设置为0?)才能删除该边框。

I also want to do this using CSS, and not declaratively from within the main JavaFX script. However, I am having trouble figuring out what CSS property I need to use (er, set to 0?) in order to remove that border.

推荐答案

从代码中删除任何控件的聚焦环显示:

To remove the focus ring display from any control from within code:

control.setStyle("-fx-focus-color: transparent;");

要删除所有控件的焦点响铃,请应用样式表:

To remove the focus ring for all controls, apply a stylesheet:

.root { -fx-focus-color: transparent; }

要仅删除所有按钮的响铃,请使用:

To only remove the ring for all buttons, use:

.button { -fx-focus-color: transparent; }

我找到 -fx-focus-color 属性设置比依靠一些奇怪的插入组合更直接,以移除焦点环。

I find the -fx-focus-color attribute setting more straight-forward than relying on some weird combination of insets to remove the focus ring.

此外,您可以使用相同的设置将聚焦环更改为其他颜色,例如 -fx-focus-color:firebrick

In addition, you can use the same setting to change the focus ring to a different color, such as -fx-focus-color: firebrick.

2015年1月20日更新

JavaFX 8附带了一个新的默认用户代理样式表(和Jens Deter关于。请注意,遗憾的是,Jens Deter的博客链接有一些烦人的弹出窗口。

For more information and alternate solutions, review James_D's answer to Remove blue frame from JavaFX input field and Jens Deter's blog post about How to get rid of focus highlighting in JavaFX. Be aware that the link to Jens Deter's blog unfortunately has some annoying pop-ups.

这篇关于如何删除JavaFX按钮的默认边框发光(选中时)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 09:17