JavaFx: tab rounded corners

后端 未结 3 2068
故里飘歌
故里飘歌 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:09

    So lets suppose that it's a bug, and you css is fine, the only solution i see for now is to remove and add default styles after some delay. Something like this:

     Tab tab = new Tab("Tab " + (tabs.getTabs().size() + 1));
     tabs.getTabs().add(tab);
     new Thread(()-> {
         try {
             Thread.sleep(50);
         } catch (InterruptedException e) {
             e.printStackTrace();
         }
         Platform.runLater(()->{
               tabs.getStyleClass().remove("tab-pane");
               tabs.getStyleClass().add("tab-pane");
         });
     }).start();
    

    Nasty hack to be honest, but it works for me:enter image description here

提交回复
热议问题