changeset 308:e5bcfe6d1fd6

RT-18958 - ScrollPane: NullPointerException when no content is set
author mickf
date Tue, 24 Jan 2012 15:59:50 +0000
parents a5e9c6a82052
children 4dd37d3f9ca9 3c8653f1768b
files javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ScrollPaneSkin.java javafx-ui-controls/test/com/sun/javafx/scene/control/skin/ScrollPaneSkinTest.java
diffstat 2 files changed, 23 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ScrollPaneSkin.java	Tue Jan 24 15:49:54 2012 +1300
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ScrollPaneSkin.java	Tue Jan 24 15:59:50 2012 +0000
@@ -720,7 +720,7 @@
         final double contentw = getSkinnable().getWidth() - getInsets().getLeft() - getInsets().getRight();
         return (getSkinnable().getHbarPolicy().equals(ScrollBarPolicy.NEVER)) ? false :
                    ((getSkinnable().getHbarPolicy().equals(ScrollBarPolicy.ALWAYS)) ? true :
-                    ((getSkinnable().isFitToWidth() && scrollNode.isResizable()) ?
+                    ((getSkinnable().isFitToWidth() && scrollNode != null ? scrollNode.isResizable() : false) ?
                        (nodeWidth > contentw && scrollNode.minWidth(-1) > contentw) : (nodeWidth > contentw)));
     }
 
@@ -728,7 +728,7 @@
         final double contenth = getSkinnable().getHeight() - getInsets().getTop() - getInsets().getBottom();
         return (getSkinnable().getVbarPolicy().equals(ScrollBarPolicy.NEVER)) ? false :
                   ((getSkinnable().getVbarPolicy().equals(ScrollBarPolicy.ALWAYS)) ? true :
-                      ((getSkinnable().isFitToHeight() && scrollNode.isResizable()) ?
+                      ((getSkinnable().isFitToHeight() && scrollNode != null ? scrollNode.isResizable() : false) ?
                        (nodeHeight > contenth && scrollNode.minHeight(-1) > contenth) : (nodeHeight > contenth)));
 
     }
--- a/javafx-ui-controls/test/com/sun/javafx/scene/control/skin/ScrollPaneSkinTest.java	Tue Jan 24 15:49:54 2012 +1300
+++ b/javafx-ui-controls/test/com/sun/javafx/scene/control/skin/ScrollPaneSkinTest.java	Tue Jan 24 15:59:50 2012 +0000
@@ -545,6 +545,27 @@
         assertTrue(skin.isVSBarVisible() & skin.isHSBarVisible());
     }
 
+    /*
+    ** check if ScrollBars appear if fitToHeight & fitToWidth are true but height is < minHeight & width is < minWidth
+    */
+    @Test public void checkWeHandleNullContent() {
+        
+    
+        scrollPane.setFitToWidth(true);
+
+        Scene scene = new Scene(scrollPane);
+ 
+        Stage stage = new Stage();
+        stage.setScene(scene);
+               
+        stage.setWidth(600);
+        stage.setHeight(600);
+ 
+        stage.show();
+
+    }
+
+    
     public static final class ScrollPaneSkinMock extends ScrollPaneSkin {
         boolean propertyChanged = false;
         int propertyChangeCount = 0;