document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. import javafx.application.Application;
  2. import javafx.geometry.Insets;
  3. import javafx.scene.Scene;
  4. import javafx.scene.control.Button;
  5. import javafx.scene.layout.FlowPane;
  6. import javafx.stage.Stage;
  7.  
  8. /**
  9.  *
  10.  * @web http://zoranpavlovic.blogspot.com/
  11.  */
  12. public class FlowPaneMain extends Application {
  13.  
  14.     /**
  15.      * @param args the command line arguments
  16.      */
  17.     public static void main(String[] args) {
  18.         launch(args);
  19.     }
  20.      
  21.     @Override
  22.     public void start(Stage primaryStage) {
  23.         primaryStage.setTitle("FlowPane example");
  24.        
  25.         //Adding FlowPane
  26.         FlowPane flowPane = new FlowPane();
  27.         flowPane.setPadding(new Insets(10, 10, 10,10));
  28.         flowPane.setVgap(4);
  29.         flowPane.setHgap(4);
  30.         // preferred width allows for two columns
  31.         flowPane.setPrefWrapLength(210);
  32.                      
  33.         Button btn = new Button();
  34.              
  35.         for(int i=0; i<8; i++){
  36.                    
  37.                 btn = new Button("Button");
  38.                 btn.setPrefSize(100, 50);
  39.                 flowPane.getChildren().add(btn);
  40.            
  41.         }
  42.                
  43.         //Adding FlowPane to the scene
  44.         Scene scene = new Scene(flowPane);
  45.         primaryStage.setScene(scene);
  46.         primaryStage.show();
  47.     }
  48. }
');