public final void enableRenaming ( final String picturePath ) { HBox hb = new HBox ( ) ; ImageView iv = getIcon ( picturePath ) ; iv . setOnMouseClicked ( new EventHandler < Event > ( ) { @ Override public void handle ( Event mouseEvent ) { if ( ( ( MouseEvent ) mouseEvent ) . getButton ( ) . equals ( MouseButton . PRIMARY ) ) { if ( ( ( MouseEvent ) mouseEvent ) . getClickCount ( ) == 2 ) { TextInputDialog input = new TextInputDialog ( textProperty ( ) . get ( ) ) ; input . setTitle ( MessagesUtil . getString ( "dajlab.change_tab_title" ) ) ; input . setContentText ( null ) ; input . setHeaderText ( MessagesUtil . getString ( "dajlab.change_tab_text" ) ) ; input . setGraphic ( null ) ; Optional < String > ret = input . showAndWait ( ) ; if ( ret . isPresent ( ) && StringUtils . isNoneBlank ( ret . get ( ) ) ) { updateTitle ( ret . get ( ) ) ; } } } } } ) ; // Without HBox, the click event is not detected ?? hb . getChildren ( ) . add ( iv ) ; setGraphic ( hb ) ; }
If used this method allows the renaming of a tab by the user with a double - click on the icon of the tab . It seems there is no mouse event on a Tab title that s why an icon should be used .