JavaFx: tab rounded corners

后端 未结 3 2066
故里飘歌
故里飘歌 2021-01-12 20:46

To make my tab corners rounded I use the following code:

.tab {
    -fx-border-radius: 10 10 0 0;
    -fx-background-radius: 10 10 0 0;
}

.tab:selected .focu         


        
3条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-12 21:30

    This is an already reported bug https://javafx-jira.kenai.com/browse/RT-40462

    UPDATE The bug has moved to the openjdk bugtracking system:

    https://bugs.openjdk.java.net/browse/JDK-8090243

    Some of your code was redundant. So this should work.

    .tab:selected .focus-indicator {
        -fx-border-radius: 10 10 0 0, 10 10 0 0;
        -fx-border-insets: -6 -9 -8 -8, -5 -8 -7 -7;
    }
    /*
    .tab-pane > .tab-header-area > .headers-region > .tab:selected{
        -fx-border-insets: 0 1 1 0, 1 2 0 1, 2 3 0 2;
    }
    */
    .tab-pane > .tab-header-area > .headers-region > .tab > .tab-container > .tab-label {
        -fx-padding:0 10 0 0;
    }
    
    .tab-header-area .tab{
        -fx-padding:4 10 5 10;
        -fx-background-radius: 10 10 0 0;
    }
    

    This will look like that:

    enter image description here

    UPDATE

    But if you really only want to have more radius to the rounded corners, this is all you have to do:

    .tab-pane > .tab-header-area > .headers-region > .tab {
        /* if outer border should be 10 radius */
        -fx-background-radius: 10 10 0 0, 9 9 0 0, 8 8 0 0;
    }
    
    .tab-pane:focused > .tab-header-area > .headers-region > .tab:selected .focus-indicator {
        -fx-border-radius: 9 9 0 0, 8 8 0 0;
    }
    

    UPDATE

    This is what I get from your code. There is a strange behaviour when adding a newly created tab. So I made a gif to show how the mouseover is working.

    enter image description here

    UPDATE

提交回复
热议问题