Search code examples
javafxlabelvboxhbox

JavaFX set title to be removed on the left side


My problem is described in the picture below. I just want to set the label to be "..."-ed on the left side and not on the right since this is the more important part. As of the code I could show you how I set my label (but that shouldn't really matter):

final Label directory = new Label();

directory.setText(selectedDirectory.getPath());

Problem


Solution

  • You can do

    directory.setStyle("-fx-text-overrun: leading-ellipsis;");
    

    or, in an external style sheet:

    .label {
        -fx-text-overrun: leading-ellipsis ;
    }