BorderPane:方位布局
package fx.com;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
public class Mian2 extends Application{
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) throws Exception {
AnchorPane a1=new AnchorPane();
a1.setStyle("-fx-background-color:#007d65");
a1.setPrefWidth(100);
a1.setPrefHeight(100);
AnchorPane a2=new AnchorPane();
a2.setStyle("-fx-background-color:#472d56");
a2.setPrefWidth(100);
a2.setPrefHeight(100);
AnchorPane a3=new AnchorPane();
a3.setStyle("-fx-background-color:#f6f5ec");
a3.setPrefWidth(100);
a3.setPrefHeight(100);
AnchorPane a4=new AnchorPane();
a4.setStyle("-fx-background-color:#7c8577");
a4.setPrefWidth(100);
a4.setPrefHeight(100);
AnchorPane a5=new AnchorPane();
a5.setStyle("-fx-background-color:#decb00");
a5.setPrefWidth(100);
a5.setPrefHeight(100);
BorderPane borp=new BorderPane();
borp.setStyle("-fx-background-color:#B23AEE");
borp.setTop(a1);
borp.setLeft(a2);
borp.setRight(a3);
borp.setBottom(a4);
borp.setCenter(a5);
Scene scene=new Scene(borp);
stage.setScene(scene);
stage.setTitle("javafx");
stage.setWidth(800);
stage.setHeight(800);
stage.show();
}
}