2017-02-25 3 views
0

ich automatisch eine Bildlaufleiste angezeigt werden soll, wenn das Fenster sein abele Größe verändert wird, um alle Rechtecken, wie ich flowpane scroll machen kann, wenn die Größe verändert

vor Ändern der Größe, um zu sehen:
befor resizing

nach Größe ändern:
after resizing

in der Unterseite verschwinden die Rechtecke, aber sie sind immer noch da. also gibt es eine Möglichkeit, die Flowpane mit einer Scrollpane zu kombinieren?

Ich verwende SceneBuilder und dies ist der fxml Code:

<?xml version="1.0" encoding="UTF-8"?> 

<?import javafx.scene.layout.FlowPane?> 
<?import javafx.scene.shape.Rectangle?> 


<FlowPane alignment="TOP_CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1"> 
    <children> 
     <Rectangle arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="200.0" stroke="BLACK" strokeType="INSIDE" width="200.0" /> 
     <Rectangle arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="200.0" stroke="BLACK" strokeType="INSIDE" width="200.0" /> 
     <Rectangle arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="200.0" stroke="BLACK" strokeType="INSIDE" width="200.0" /> 
     <Rectangle arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="200.0" stroke="BLACK" strokeType="INSIDE" width="200.0" /> 
     <Rectangle arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="200.0" stroke="BLACK" strokeType="INSIDE" width="200.0" /> 
     <Rectangle arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="200.0" stroke="BLACK" strokeType="INSIDE" width="200.0" /> 
    </children> 
</FlowPane> 

Antwort

0

Ja gibt es: Einfach den FlowPane als Inhalt für die ScrollPane verwenden und fitToWidth die ScrollPane machen zu machen verwenden Sie die Breite des Inhalts nach der verfügbaren Breite ...

<?xml version="1.0" encoding="UTF-8"?> 

<?import javafx.scene.control.ScrollPane?> 
<?import javafx.scene.layout.FlowPane?> 
<?import javafx.scene.shape.Rectangle?> 

<!-- make ScrollPane resize the content width --> 
<ScrollPane fitToWidth="true" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1"> 
    <content> 
     <!-- do not put bounds on the FlowPane size --> 
     <FlowPane alignment="TOP_CENTER" maxHeight="-Infinity" maxWidth="Infinity" minHeight="-Infinity" prefWidth="600.0"> 
     <children> 
      <Rectangle arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="200.0" stroke="BLACK" strokeType="INSIDE" width="200.0" /> 
      <Rectangle arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="200.0" stroke="BLACK" strokeType="INSIDE" width="200.0" /> 
      <Rectangle arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="200.0" stroke="BLACK" strokeType="INSIDE" width="200.0" /> 
      <Rectangle arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="200.0" stroke="BLACK" strokeType="INSIDE" width="200.0" /> 
      <Rectangle arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="200.0" stroke="BLACK" strokeType="INSIDE" width="200.0" /> 
      <Rectangle arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="200.0" stroke="BLACK" strokeType="INSIDE" width="200.0" /> 
     </children> 
     </FlowPane> 
    </content> 
</ScrollPane> 
+0

danke für die Hilfe –

Verwandte Themen