日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

如何摆脱JavaFX中的重点突出显示

發(fā)布時間:2023/12/3 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 如何摆脱JavaFX中的重点突出显示 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

今天,有人問我是否知道擺脫JavaFX控件(分別是按鈕)的焦點突出的方法:



有關(guān)此問題的大多數(shù)文章和提示建議添加:

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

但是使用這種樣式,仍然會留下這樣的光芒:

為了擺脫這種光芒,通常還建議額外使用-fx-background-insets :

.button:focused {-fx-focus-color: transparent; -fx-background-insets: -1.4, 0, 1, 2; }

但這導致呈現(xiàn)的按鈕沒有外部邊框:

與默認按鈕樣式相比:

這仍然是一種“突出”。

(為什么實際上有4個插入值?)

看一下modena.css定義的JavaFX默認樣式,可以modena.css更多信息:

/* A bright blue for the focus indicator of objects. Typically used as the * first color in -fx-background-color for the "focused" pseudo-class. Also * typically used with insets of -1.4 to provide a glowing effect. */ -fx-focus-color: #f25f29; -fx-faint-focus-color: #f25f2933;

顯然,不僅有一種焦點顏色-fx-focus-color而且還有-fx-faint-focus-color ,它旨在創(chuàng)建這種發(fā)光效果(設置-fx-focus-color:transparent;時仍然存在)。

仔細查看.button:focused偽類(在modena.css ):

.button:focused {-fx-background-color: -fx-faint-focus-color, -fx-focus-color, -fx-inner-border, -fx-body-color; -fx-background-insets: -2, -0.3, 1, 2;-fx-background-radius: 7, 6, 4, 3; }

玩一些極端的色彩可以揭示這種安排:

.button:focused {-fx-focus-color: red;-fx-faint-focus-color: green;-fx-inner-border: blue;-fx-body-color: orange;-fx-background-color: -fx-faint-focus-color, -fx-focus-color, -fx-inner-border, -fx-body-color; -fx-background-insets: -2, -0.3, 1, 2;-fx-background-radius: 7, 6, 4, 3; }


回到主題可能是刪除焦點突出顯示的一個聰明方法是對.button:focus也使用默認按鈕樣式(其他控件使用相同的方法):

.button:focused {-fx-background-color: -fx-outer-border, -fx-inner-border, -fx-body-color; -fx-background-insets: 0, 1, 2;-fx-background-radius: 5, 4, 3; }

翻譯自: https://www.javacodegeeks.com/2014/11/how-to-get-rid-of-focus-highlighting-in-javafx.html

總結(jié)

以上是生活随笔為你收集整理的如何摆脱JavaFX中的重点突出显示的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。