0

I have a tab pane and I want all tab headers to have the same width. So I did:

.tab-header-area .tab{
    -fx-min-width:200;
    -fx-pref-width:200;
    -fx-max-width:200;
}

The problem is that if text is longer than the space it has than the label is messed with the close button. How can I make .tab > .tab-container > .tab-label cut the text and add "..." at the end?

1 Answers1

1

Code option:

TabPane pane = new TabPane();
pane.setTabMinWidth(200);
pane.setTabMaxWidth(200);

Css Options

.tab-pane{
    -fx-tab-min-width:200;
    -fx-tab-max-width:200;
}

enter image description here

Old solution:

You have to set -fx-max-width for .tab > .tab-container > .tab-label There are 2 options:

1) Set the default sizes for label and not tab (selected tab will be a little bit larger with x button in it):

.tab-pane > .tab-header-area > .headers-region > .tab > .tab-container > .tab-label {
    -fx-min-width:200;
    -fx-pref-width:200;
    -fx-max-width:200;
}

2) Use your css and some smaller value for labels(This way all tabs will be always 200 px):

.tab-header-area .tab{
    -fx-min-width:200;
    -fx-pref-width:200;
    -fx-max-width:200;
}

.tab-pane > .tab-header-area > .headers-region > .tab > .tab-container > .tab-label {
   -fx-min-width:175;
   -fx-pref-width:175;
   -fx-max-width:175;
}
varren
  • 14,551
  • 2
  • 41
  • 72
  • Thank you. You again helped me, I will accept your question as soon as I try it. Could you take a look at this http://stackoverflow.com/questions/30690918/javafx-tab-rounded-corners - it's very important for me but I can't solve it. –  Jun 07 '15 at 18:28
  • @iJava take a look one more time. I found out better solution) – varren Jun 09 '15 at 07:13
  • Thanks! It's really better! –  Jun 09 '15 at 07:24