{"id":1245,"date":"2014-07-03T02:01:38","date_gmt":"2014-07-03T00:01:38","guid":{"rendered":"http:\/\/www.jensd.de\/wordpress\/?p=1245"},"modified":"2014-07-03T16:22:10","modified_gmt":"2014-07-03T14:22:10","slug":"how-to-get-rid-of-focus-highlighting-in-javafx","status":"publish","type":"post","link":"https:\/\/www.jensd.de\/wordpress\/?p=1245","title":{"rendered":"How to get rid of focus highlighting in JavaFX"},"content":{"rendered":"<p>Today I was asked if I know a way to get rid of the focus-highlighting of JavaFX controls  \t(respectively buttons):<\/p>\n<p><a href=\"http:\/\/www.jensd.de\/wordpress\/wp-content\/uploads\/2014\/07\/button_hover.jpg\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1253\" data-permalink=\"https:\/\/www.jensd.de\/wordpress\/?attachment_id=1253\" data-orig-file=\"https:\/\/www.jensd.de\/wordpress\/wp-content\/uploads\/2014\/07\/button_hover.jpg\" data-orig-size=\"186,59\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"button_hover\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/www.jensd.de\/wordpress\/wp-content\/uploads\/2014\/07\/button_hover.jpg\" data-large-file=\"https:\/\/www.jensd.de\/wordpress\/wp-content\/uploads\/2014\/07\/button_hover.jpg\" tabindex=\"0\" role=\"button\" src=\"http:\/\/www.jensd.de\/wordpress\/wp-content\/uploads\/2014\/07\/button_hover.jpg\" alt=\"button_hover\" width=\"186\" height=\"59\" class=\"aligncenter size-full wp-image-1253\" \/><\/a><\/p>\n<p>Most posts and tipps regarding this issue suggesting to adding:<\/p>\n<p>[css]<br \/>\n.button:focused {<br \/>\n    -fx-focus-color: transparent;<br \/>\n}<br \/>\n[\/css]<\/p>\n<p>But with this style a glow like this is still left:<\/p>\n<p><a href=\"http:\/\/www.jensd.de\/wordpress\/wp-content\/uploads\/2014\/07\/button_glow.jpg\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1248\" data-permalink=\"https:\/\/www.jensd.de\/wordpress\/?attachment_id=1248\" data-orig-file=\"https:\/\/www.jensd.de\/wordpress\/wp-content\/uploads\/2014\/07\/button_glow.jpg\" data-orig-size=\"188,62\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"button_glow\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/www.jensd.de\/wordpress\/wp-content\/uploads\/2014\/07\/button_glow.jpg\" data-large-file=\"https:\/\/www.jensd.de\/wordpress\/wp-content\/uploads\/2014\/07\/button_glow.jpg\" tabindex=\"0\" role=\"button\" src=\"http:\/\/www.jensd.de\/wordpress\/wp-content\/uploads\/2014\/07\/button_glow.jpg\" alt=\"button_glow\" width=\"188\" height=\"62\" class=\"aligncenter size-full wp-image-1248\" \/><\/a><\/p>\n<p>To get rid of this glow also often suggested to play around with <code>-fx-background-insets<\/code> additionally:<br \/>\n[css]<br \/>\n.button:focused {<br \/>\n    -fx-focus-color: transparent;<br \/>\n    -fx-background-insets: -1.4, 0, 1, 2;<br \/>\n}<br \/>\n[\/css]<\/p>\n<p>But this results in a button rendered with out an outer border:<\/p>\n<p><a href=\"http:\/\/www.jensd.de\/wordpress\/wp-content\/uploads\/2014\/07\/button_insets.jpg\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1259\" data-permalink=\"https:\/\/www.jensd.de\/wordpress\/?attachment_id=1259\" data-orig-file=\"https:\/\/www.jensd.de\/wordpress\/wp-content\/uploads\/2014\/07\/button_insets.jpg\" data-orig-size=\"185,60\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"button_insets\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/www.jensd.de\/wordpress\/wp-content\/uploads\/2014\/07\/button_insets.jpg\" data-large-file=\"https:\/\/www.jensd.de\/wordpress\/wp-content\/uploads\/2014\/07\/button_insets.jpg\" tabindex=\"0\" role=\"button\" src=\"http:\/\/www.jensd.de\/wordpress\/wp-content\/uploads\/2014\/07\/button_insets.jpg\" alt=\"button_insets\" width=\"185\" height=\"60\" class=\"aligncenter size-full wp-image-1259\" \/><\/a><\/p>\n<p>Compared to the default button style<\/p>\n<p><a href=\"http:\/\/www.jensd.de\/wordpress\/wp-content\/uploads\/2014\/07\/button.jpg\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1260\" data-permalink=\"https:\/\/www.jensd.de\/wordpress\/?attachment_id=1260\" data-orig-file=\"https:\/\/www.jensd.de\/wordpress\/wp-content\/uploads\/2014\/07\/button.jpg\" data-orig-size=\"184,59\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"button\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/www.jensd.de\/wordpress\/wp-content\/uploads\/2014\/07\/button.jpg\" data-large-file=\"https:\/\/www.jensd.de\/wordpress\/wp-content\/uploads\/2014\/07\/button.jpg\" tabindex=\"0\" role=\"button\" src=\"http:\/\/www.jensd.de\/wordpress\/wp-content\/uploads\/2014\/07\/button.jpg\" alt=\"button\" width=\"184\" height=\"59\" class=\"aligncenter size-full wp-image-1260\" \/><\/a><\/p>\n<p>this is still a kind of &#8220;highlighting&#8221;:<\/p>\n<p><strong>Why is that? (And why are there actually 4 inset values ?)<\/strong><br \/>\n(note he comment of David Grieve below)<\/p>\n<p>Having a look at the JavaFX default style as defined by <code><strong>modena.css<\/strong><\/code> bares some more information:<br \/>\n<code><br \/>\n\/* A bright blue for the focus indicator of objects. Typically used as the<br \/>\n  * first color in -fx-background-color for the \"focused\" pseudo-class. Also<br \/>\n  * typically used with insets of -1.4 to provide a glowing effect.<br \/>\n  *\/<br \/>\n  -fx-focus-color: #f25f29;<br \/>\n  -fx-faint-focus-color: #f25f2933;<br \/>\n<\/code><\/p>\n<p>Obviously there is not only one focus color <code>-fx-focus-color<\/code> but also <code><strong>-fx-faint-focus-color<\/strong><\/code> which is meant to create this glow-effect (that is remaining when setting <code>-fx-focus-color:transparent;<\/code>).<\/p>\n<p>A closer look at the .button:focused pseudo class (in <code>modena.css<\/code>):<br \/>\n[css]<br \/>\n.button:focused {<br \/>\n    -fx-background-color: -fx-faint-focus-color, -fx-focus-color, -fx-inner-border, -fx-body-color;<br \/>\n    -fx-background-insets: -2, -0.3, 1, 2;<br \/>\n    -fx-background-radius: 7, 6, 4, 3;<br \/>\n}<br \/>\n[\/css]<\/p>\n<p>Playing around with some (extreme ;-)) colouring reveals the arrangement:<\/p>\n<p>[css]<br \/>\n.button:focused {<br \/>\n    -fx-focus-color: red;<br \/>\n    -fx-faint-focus-color: green;<br \/>\n    -fx-inner-border: blue;<br \/>\n    -fx-body-color: orange;<\/p>\n<p>    -fx-background-color: -fx-faint-focus-color, -fx-focus-color, -fx-inner-border, -fx-body-color;<br \/>\n    -fx-background-insets: -2, -0.3, 1, 2;<br \/>\n    -fx-background-radius: 7, 6, 4, 3;<br \/>\n}<br \/>\n[\/css]<\/p>\n<p><a href=\"http:\/\/www.jensd.de\/wordpress\/wp-content\/uploads\/2014\/07\/button_hover_style.jpg\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1254\" data-permalink=\"https:\/\/www.jensd.de\/wordpress\/?attachment_id=1254\" data-orig-file=\"https:\/\/www.jensd.de\/wordpress\/wp-content\/uploads\/2014\/07\/button_hover_style.jpg\" data-orig-size=\"349,114\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"button_hover_style\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/www.jensd.de\/wordpress\/wp-content\/uploads\/2014\/07\/button_hover_style-300x97.jpg\" data-large-file=\"https:\/\/www.jensd.de\/wordpress\/wp-content\/uploads\/2014\/07\/button_hover_style.jpg\" tabindex=\"0\" role=\"button\" src=\"http:\/\/www.jensd.de\/wordpress\/wp-content\/uploads\/2014\/07\/button_hover_style.jpg\" alt=\"button_hover_style\" width=\"349\" height=\"114\" class=\"aligncenter size-full wp-image-1254\" srcset=\"https:\/\/www.jensd.de\/wordpress\/wp-content\/uploads\/2014\/07\/button_hover_style.jpg 349w, https:\/\/www.jensd.de\/wordpress\/wp-content\/uploads\/2014\/07\/button_hover_style-300x97.jpg 300w\" sizes=\"(max-width: 349px) 100vw, 349px\" \/><\/a><\/p>\n<p>Getting back to the topic maybe a clent way to remove the focus hightlight is to use the default button styles also for .button:focus (same approach for other controls):<\/p>\n<p>[css]<br \/>\n.button:focused {<br \/>\n    -fx-background-color: -fx-outer-border, -fx-inner-border, -fx-body-color;<br \/>\n    -fx-background-insets: 0, 1, 2;<br \/>\n    -fx-background-radius: 5, 4, 3;<br \/>\n}<br \/>\n[\/css]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today I was asked if I know a way to get rid of the focus-highlighting of JavaFX controls (respectively buttons): Most posts and tipps regarding this issue suggesting to adding: [css] .button:focused { -fx-focus-color: transparent; } [\/css] But with this style a glow like this is still left: To get rid of this glow also&hellip; <span class=\"clear\"><\/span><a href=\"https:\/\/www.jensd.de\/wordpress\/?p=1245\" class=\"more-link read-more\" rel=\"bookmark\">Continue Reading <span class=\"screen-reader-text\">How to get rid of focus highlighting in JavaFX<\/span><i class=\"fa fa-arrow-right\"><\/i><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"footnotes":"","_jetpack_memberships_contains_paid_content":false,"jetpack_publicize_message":"Get rid of focus highlighting in JavaFX","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[32,9,4,8,47,6],"tags":[93,80,76,103,81],"jetpack_publicize_connections":[],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p38FCL-k5","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.jensd.de\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1245"}],"collection":[{"href":"https:\/\/www.jensd.de\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jensd.de\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jensd.de\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jensd.de\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1245"}],"version-history":[{"count":24,"href":"https:\/\/www.jensd.de\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1245\/revisions"}],"predecessor-version":[{"id":1866,"href":"https:\/\/www.jensd.de\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1245\/revisions\/1866"}],"wp:attachment":[{"href":"https:\/\/www.jensd.de\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1245"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jensd.de\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1245"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jensd.de\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1245"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}