title: JavaFx scroll bar with multiple images
body: <p>I have several images that need to be displayed at the same time using scenebuilder. I wanted to use a scrollbar or scroll pane to allow me to see multiple images at once. However, I can't get the scroll bar to even appear. Am I using scroll pane right?</p>
  <p>Here is a picture of scene builder: <a href="https://i.stack.imgur.com/q8idi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/q8idi.png" alt="enter image description here" /></a></p>
  <p>Here is the window running: <a href="https://i.stack.imgur.com/XpSsM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XpSsM.png" alt="enter image description here" /></a></p>
  <p>See how the last flag is cut off? I need to scroll down.</p>
  <p>In my code, when I try adding the flowpane with all the images to a scrollpane, I get errors and no scroll bar.</p>
  <pre><code>public class SampleController {
      
      @FXML private ListView&lt;String&gt; list1;
      
      private ImageView[] imageViews1 = {new ImageView(&quot;file:/C:/Users/Pictures/US.png&quot;),
              new ImageView(&quot;file:/C:/Users/Pictures/china.png&quot;),
              new ImageView(&quot;file:/C:/Users/Pictures/pakistan.png&quot;),
              new ImageView(&quot;file:/C:/Users/Pictures/italy.png&quot;),
              new ImageView(&quot;file:/C:/Users/Pictures/newzealand.png&quot;),
              new ImageView(&quot;file:/C:/Users/Pictures/hungary.png&quot;),
              new ImageView(&quot;file:/C:/Users/Pictures/russia.png&quot;),
              new ImageView(&quot;file:/C:/Users/Pictures/mexico.png&quot;),
              new ImageView(&quot;file:/C:/Users/Pictures/cambodia.png&quot;)};
      
      @FXML private ImageView displayWin;
      @FXML private FlowPane imagePane = new FlowPane();
      @FXML private ScrollPane flagScroll;
      
  public void initialize()
  {
      
      ObservableList&lt;String&gt; data = FXCollections.observableArrayList(&quot;United States of America&quot;, &quot;China&quot;, &quot;Pakistan&quot;, &quot;Italy&quot;, &quot;New Zealand&quot;, &quot;Hungary&quot;, 
                &quot;Russia&quot;, &quot;Mexico&quot;, &quot;Cambodia&quot;);
      list1.setItems(data);
      list1.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
      
      
      
      list1.getSelectionModel().selectedItemProperty().addListener(new ChangeListener&lt;String&gt;()
              {
                  
                  public void changed(ObservableValue&lt;? extends String&gt; observable, String oldValue, String newValue)
                  {
                      imagePane.getChildren().clear();
                      for(Integer i : list1.getSelectionModel().getSelectedIndices()) {
                          imagePane.getChildren().add(imageViews1[i]);
                      }
                  }           
              });
      
  
  }
  }
  </code></pre>
  <p>I found this thread but it did not help <a href="https://stackoverflow.com/questions/39605571/javafx-add-node-to-scrollpane-with-scenebuilder">JavaFX Add Node to ScrollPane with SceneBuilder</a>
  I tried to do what this video said also to no avail <a href="https://www.youtube.com/watch?v=gqg3HW73aws&amp;t=259s" rel="nofollow noreferrer">https://www.youtube.com/watch?v=gqg3HW73aws&amp;t=259s</a>.</p>
  <p><strong><strong><strong>EDIT</strong></strong></strong>**
  I need to use a scroll bar control. Scrollpane or listview won't do</p>