Results 1 to 3 of 3
  1. #1
    Halfbax is offline Member
    Join Date
    Aug 2015
    Posts
    6
    Rep Power
    0

    Default Cant center a FlowPane in a BorderPane

    Huhu,

    I cannot position the object feldRoot to the true center. You can see it in the image. What's the problem?



    Java FX Code:
    import javafx.application.Application;
    import javafx.scene.Scene;
    import javafx.scene.control.Label;
    import javafx.scene.layout.Background;
    import javafx.scene.layout.BackgroundFill;
    import javafx.scene.layout.BorderPane;
    import javafx.scene.layout.FlowPane;
    import javafx.scene.paint.Color;
    import javafx.scene.shape.Rectangle;
    import javafx.stage.Stage;
    
    public class Arbeitsfläche extends Application {
        public static void main(String[] args) {
            launch(args);
        }
    
        private BorderPane root = new BorderPane();    
        private FlowPane feldRoot = new FlowPane();    
        private Rectangle[] feld = new Rectangle[20];
        private Label build = new Label();
        private Revision rev = new Revision();
        
        @Override
        public void start(Stage primaryStage) throws Exception {
            primaryStage.setTitle("Hallo Welt");
            root.setBackground(new Background(new BackgroundFill(Color.BLACK, null, null)));
            
            feldRoot.setVgap(5);
            feldRoot.setHgap(10);
            feldRoot.setMaxWidth(2100);
            
            for(int i = 0; i < 20; i++) {
                feld[i] = new Rectangle(200,250,Color.WHITE);
                feldRoot.getChildren().add(feld[i]);
            }
            
            build.setTextFill(Color.WHITE);
            build.setText("Build " + rev.getVersion() + " // " + rev.getDate());
            
            root.setBottom(build);
            root.setCenter(feldRoot);
            
            Scene scene = new Scene(root, 800, 600);
            
            primaryStage.setScene(scene);
            primaryStage.setFullScreen(true);
            primaryStage.show();
        }
    
    }

  2. #2
    Halfbax is offline Member
    Join Date
    Aug 2015
    Posts
    6
    Rep Power
    0

    Default Re: Cant center a FlowPane in a BorderPane

    #Solved
    Java FX Code:
    feldRoot.setMaxHeight(500);

  3. #3
    benji2505 is offline Senior Member
    Join Date
    Sep 2014
    Location
    MA, USA
    Posts
    398
    Rep Power
    5

    Default Re: Cant center a FlowPane in a BorderPane

    try this:

    root.setAlignment(feldroot, Pos.Center);

Similar Threads

  1. buttons won't center
    By gib65 in forum AWT / Swing
    Replies: 4
    Last Post: 10-07-2010, 07:49 PM
  2. jsf center tag needed
    By Srikala in forum JavaServer Faces (JSF)
    Replies: 5
    Last Post: 07-27-2009, 11:49 AM
  3. center a form
    By tommy in forum New To Java
    Replies: 2
    Last Post: 08-06-2007, 08:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •