Issue
I am trying to create a tab system, with similar function to tabs in Chrome, where there is a cross on each tab to close it, like this:
With JavaFX, I can get close, by setting the tabpane closing policy to ALL_TABS
. Unfortunately this means my new tab button (also a tab iself) can be closed:
I am aware of the SELECTED_TAB
rule, which would fix this problem, but this would defeat the purpose. I am not aware of any other closing policy that would allow exceptions to the ALL_TABS
rule.
I tried adding my own cross to each tab individually using the setGraphic
method for the Tab
class, however I couldn't figure out how to handle that mouse click event such that it closed the correct tab.
I realise I could also make the new tab button something other than a tab, but I wouldn't really know how to integrate that with the tab pane.
So, is there a simpler method that I'm not seeing? If not, then how can I achieve this kind of tabbing system in JavaFX?
Solution
plusTab.setClosable(false);
I did a simple skim of the documentation. Will this work?
Answered By - JCamacho