TableView: column widths computed for the contents of the cells and ignorant header

Hallo,

I use the tableview component. The header font size is higher then that of the cells. The problem is: the width of the column based on the cell that contains the longest string, and if the header-string has a length, then the header is truncated (it shows the points of suspension) and I need to change the width of column manually. How could I solve this problem? The easiest way would be to calculate the width of column on myself. I can't find any method in javafx, allowing to calculate the width of the string in pixels. Bat there is the FontMetrics class and the Graphics class, so it's easy to get the width in pixels. There pendants to this course in JavaFX?

regarding

Rafal Z

It is indeed a problem valid and I had only a short time consuming solution. You can create a new instance of a few well-chosen javafx.scene.Node and apply the same style you have in your column header. You would then proceed with

new Scene( new Group( YourNode ) );
YourNode.applyCss( );
YourColumn.setPrefWidth( YourNode.getLayoutBounds( ).getWidth( ) );

You can get simple text width by using the javafx.scene.text.Text node, but it doesn't have some nice properties, you could use as padding.

Tags: Java

Similar Questions

Maybe you are looking for

  • When I uncheck the option MenuToolbar, my Firefox button does not appear

    Whenever I have untick the box next to the menu bar that the firefox button refuses to fill. It is only on the computer of my wife, she's running windows 7 Home premium and I did a new install of Mozilla Firefox and the button is not there for some r

  • ThinkPad Tablet - the missing card

    Hello Overall, I am that I am very happy with my Thinkpad Tablet Android (1838). But something which is a must for this tablet is the docking station for charging the Tablet faster and reliable than with a USB port. But sometimes I want to host the T

  • MX922 on OS 10.11.4 with Canon IJ Scan Utility installed - no longer works wireless

    I have a few multifuntions gun and have never had a problem of scanning more wireless - my new MX922 on OX 10.11.4 does scan no more wireless - when I open the utility and click on one of the icons, a black with small white corners box appears and th

  • CallExtractFiles failed with the error 0x8007007e.

    I get the following when Truing error to run Microsoft Update: [error number: 0x8007007E] My windowsupdate log has the following entries: Notifications of recommended is disabled.2012-10-27 23:43:20:843 472 b5c Misc = logging initialized (build: 7.6.

  • Pavilion dv5 startup question point

    This morning when I got to the top of my dv5 Pavilion (with Vista installed), after showing the logo of HP, the screen went black and does nothing else. I have repeated many times and also tried going to the start menu, all this without success. Afte