< prev index next >

modules/controls/src/main/java/com/sun/javafx/scene/control/skin/TableViewSkin.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -260,16 +260,27 @@
         double headerWidth = headerTextWidth + headerGraphicWidth + 10 + header.snappedLeftInset() + header.snappedRightInset();
         maxWidth = Math.max(maxWidth, headerWidth);
 
         // RT-23486
         maxWidth += padding;
-        if(tableView.getColumnResizePolicy() == TableView.CONSTRAINED_RESIZE_POLICY) {
-            maxWidth = Math.max(maxWidth, tc.getWidth());
+        if (tableView.getColumnResizePolicy() == TableView.CONSTRAINED_RESIZE_POLICY && tableView.getWidth() > 0) {
+
+            if (maxWidth > tc.getMaxWidth()) {
+                maxWidth = tc.getMaxWidth();
+            }
+
+            int size = tc.getColumns().size();
+            if (size > 0) {
+                resizeColumnToFitContent(tc.getColumns().get(size - 1), maxRows);
+                return;
         }
 
+            resizeColumn(tc, Math.round(maxWidth - tc.getWidth()));
+        } else {
         tc.impl_setWidth(maxWidth);
     }
+    }
 
     /** {@inheritDoc} */
     @Override public int getItemCount() {
         return tableView.getItems() == null ? 0 : tableView.getItems().size();
     }
< prev index next >