1

how do i set an aligment regarding to each Colomn header on table view?

Example i have 2 Columns and i want to set the aligment from first column on center and as the second one on the left side.

I've already done the table content with, but can't move the header.

Changing all of the header aligment would be easy, but that is not what i want.

Here are my Table: i want the "projektdetail" set to the left:

enter image description here

Thanks in advance

Added: The answer to this: JavaFx how to align only one column-header in tableview?

I've tested the Java8 solution and it works

Community
  • 1
  • 1
Ivancodescratch
  • 405
  • 4
  • 14
  • 1
    possible duplicate of [JavaFx how to align only one column-header in tableview?](http://stackoverflow.com/questions/23576867/javafx-how-to-align-only-one-column-header-in-tableview) – Uluk Biy Jun 09 '15 at 05:43
  • @UlukBiy, yes, thanks for pointing it. I've search before but didn't find any. – Ivancodescratch Jun 09 '15 at 07:09

1 Answers1

0

You could give the column a custom class with:

tableView.getColumns().get(2).getStyleClass().add("my_class")

and then style it with css!

.column-header#my_class .label {
    -fx-alignment: LEFT;
}
MrEbbinghaus
  • 963
  • 7
  • 15
  • Hi, your code giving me idea thanks. But it didn't solve the problem. The Method "add()" didn't exist so i tried with "setStyle()" tableView.getColumns().get(1).setStyle("-fx-alignment: BASELINE_LEFT;"); . But still i can only change the content stylesheet not the header. – Ivancodescratch Jun 09 '15 at 06:09
  • 1
    My fault, it's "getStyleClass().add()". I will correct it. – MrEbbinghaus Jun 10 '15 at 08:00