Found the change: https://bugs.openjdk.org/browse/JDK-8299753 - I thought it 
went in earlier.

The resizing logic does indeed consider maximum widths (when the available 
space exceeds the sum of preferred widths), so the behavior is as designed.  
The unexpected part comes from the fact that the rest of the columns have the 
maximum sizes of 5000, and that is what we see, as it distributes less space to 
the first column.

I would suggest to set preferred widths.  Don't know whether your application 
supports restoring UI settings between sessions, but that's what I do in my 
projects: https://github.com/andy-goryachev/AppFramework

-andy




From: Cormac Redmond <credm...@certak.com>
Date: Monday, June 30, 2025 at 14:54
To: Andy Goryachev <andy.goryac...@oracle.com>
Cc: openjfx-dev@openjdk.org <openjfx-dev@openjdk.org>
Subject: [External] : Re: JFX25: TableView + col.setMaxWidth() now clipping 
column headers
Hi,

Well, it's not making much sense to me.

If you set a preferred width that's "too small", it's coming up with some other 
size (probably the 80 you're talking about):

// col1.setPrefWidth(500);
col1.setPrefWidth(25);

[cid:ii_mcjmqw874]

...but if you specify a max, the pref width is suddenly honoured:

col1.setMaxWidth(500);
col1.setPrefWidth(25);

[cid:ii_mcjmsokd5]

The above is JFX25.

I think I noticed this oddity in my application because I had prefWidths that 
were probably too small -- but JFX24 still made them fit (unbeknownst to me). 
JFX25 doesn't appear to do that though, whatever has changed there.

Thanks for the tips. Not sure if this is worth worrying about or not, but 
definitely the behaviour has changed.




Kind Regards,
Cormac

On Mon, 30 Jun 2025 at 22:29, Andy Goryachev 
<andy.goryac...@oracle.com<mailto:andy.goryac...@oracle.com>> wrote:
When using constrained resize policy, it is better to set the preferred widths 
explicitly.  Otherwise, the initial distribution is a function of default 
preferred / maximum sizes which are, if I recall correctly, are 80 and 5000 
respectively.

You can see that the first column has shrunk because of the change in the max 
width (5000 -> 500).  I am not entirely sure why setting the max width of one 
column has such an effect, it is certainly not used for initiali allocation 
except to limit the width, which is not the case in the screenshots provided.

What happens when you set the preferred width for the columns?

-andy



From: openjfx-dev 
<openjfx-dev-r...@openjdk.org<mailto:openjfx-dev-r...@openjdk.org>> on behalf 
of Cormac Redmond <credm...@certak.com<mailto:credm...@certak.com>>
Date: Saturday, June 28, 2025 at 16:42
To: openjfx-dev@openjdk.org<mailto:openjfx-dev@openjdk.org> 
<openjfx-dev@openjdk.org<mailto:openjfx-dev@openjdk.org>>
Subject: JFX25: TableView + col.setMaxWidth() now clipping column headers
Hi,

While testing JFX25 (on Windows), previously perfectly-sized column sizes are 
now "too small", hiding parts of the column header.

Code to reproduce:

public class TableViewColSizeBug extends Application {

    @Override
    public void start(Stage stage) {
        TableView<String> table = new TableView<>();
        TableColumn<String, String> col1 = new TableColumn<>();
        col1.setGraphic(new Text("Column One (... ...)"));

        
table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY_FLEX_LAST_COLUMN);

        // Setting a max width causes a "too small" column size
        col1.setMaxWidth(500); // Note large param

        table.getColumns().addAll(col1, new TableColumn<>("Col 2"), new 
TableColumn<>("Col 3"), new TableColumn<>("Col 4"), new TableColumn<>("Col 5"));
        stage.setScene(new Scene(new VBox(table), 600, 200));
        stage.show();
    }

    public static void main(String[] args) {
        launch();
    }
}


Notice the clear difference between JFX24 and JFX25 behaviour. If you do NOT 
setMaxWidth, there is no issue. For some reason, calling setMaxWidth, no matter 
how large the param, triggers this.

JFX25 (as per code above, setting a column Text graphic), col width too small:
[cid:ii_197c2cca595cb971f162]

JFX25 using "new TableColumn<>("Column One (... ...)")", instead of setting a 
Text graphic; col width also too small:
[cid:ii_197c2cca595cb971f163]

JFX25 when you do NOT do setMaxWidth(...), looks fine:

[cid:ii_197c2cca595cb971f164]
JFX24 (in all instances, looks fine):
[cid:ii_197c2cca595cb971f161]

Is this a bug?


Kind Regards,
Cormac

Reply via email to