javafx.scene.layout.BorderPane类的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(10.3k)|赞(0)|评价(0)|浏览(108)

本文整理了Java中javafx.scene.layout.BorderPane类的一些代码示例,展示了BorderPane类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BorderPane类的具体详情如下:
包路径:javafx.scene.layout.BorderPane
类名称:BorderPane

BorderPane介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

@Override
public void start(Stage stage) throws Exception {
  BorderPane pane = new BorderPane();
  ImageView img = new ImageView("http://...");

  img.fitWidthProperty().bind(stage.widthProperty()); 

  pane.setCenter(img);

  Scene scene = new Scene(pane);
  stage.setScene(scene);
  stage.show();
}

代码示例来源:origin: stackoverflow.com

public class ContactApp extends Application {

  @Override
  public void start(Stage primaryStage) throws Exception {

    BorderPane root = new BorderPane();
    FXMLLoader listLoader = new FXMLLoader(getClass().getResource("list.fxml"));
    root.setCenter(listLoader.load());
    ListController listController = listLoader.getController();

    FXMLLoader editorLoader = new FXMLLoader(getClass().getResource("editor.fxml"));
    root.setRight(editorLoader.load());
    EditorController editorController = editorLoader.getController();

    FXMLLoader menuLoader = new FXMLLoader(getClass().getResource("menu.fxml"));
    root.setTop(menuLoader.load());
    MenuController menuController = menuLoader.getController();

    DataModel model = new DataModel();
    listController.initModel(model);
    editorController.initModel(model);
    menuController.initModel(model);

    Scene scene = new Scene(root, 800, 600);
    primaryStage.setScene(scene);
    primaryStage.show();
  }
}

代码示例来源:origin: jfoenixadmin/JFoenix

forwardMonthButton.setOnAction(t -> forward(1, MONTHS, false, true));
BorderPane arrowsContainer = new BorderPane();
arrowsContainer.setLeft(backMonthButton);
arrowsContainer.setRight(forwardMonthButton);
arrowsContainer.setPadding(new Insets(4, 12, 2, 12));
arrowsContainer.setPickOnBounds(false);
return arrowsContainer;

代码示例来源:origin: stackoverflow.com

final BorderPane root = new BorderPane();
// construct your VBox
root.setCenter(vbox);

代码示例来源:origin: jfoenixadmin/JFoenix

protected BorderPane createCalendarMonthLabelPane() {
  monthYearLabel = new Label();
  monthYearLabel.getStyleClass().add(SPINNER_LABEL);
  monthYearLabel.setFont(Font.font(ROBOTO, FontWeight.BOLD, 13));
  monthYearLabel.setTextFill(DEFAULT_COLOR);
  BorderPane monthContainer = new BorderPane();
  monthContainer.setMinHeight(50);
  monthContainer.setCenter(monthYearLabel);
  monthContainer.setPadding(new Insets(2, 12, 2, 12));
  return monthContainer;
}

代码示例来源:origin: stackoverflow.com

stage.setTitle("Validation Demo");
BorderPane borderPane = new BorderPane();
borderPane.setCenter(loadLoginScreen());
Scene scene = new Scene(borderPane, 700, 500);
scene.getStylesheets().add(
    ValidationDemo.class.getResource("context.css")
        .toExternalForm());
stage.setScene(scene);
stage.show();
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(25, 25, 25, 25));
grid.add(scenetitle, 0, 0, 2, 1);
Label userName = new Label("User Name:");
grid.add(userName, 0, 1);
grid.add(userTextField, 1, 1);
Label pw = new Label("Password:");
grid.add(pw, 0, 2);
grid.add(pwBox, 1, 2);
btn.setOnAction(new EventHandler<ActionEvent>() {

代码示例来源:origin: stackoverflow.com

BorderPane root = new BorderPane();
HBox hbox = new HBox();
Button backButton = new Button("Back");
Button deleteButton = new Button("Delete");
Button showAllButton = new Button("Show All");
rightButtons.setAlignment(Pos.CENTER_RIGHT);
hbox.getChildren().addAll(backButton, rightButtons);
hbox.setPadding(new Insets(2));
root.setBottom(hbox);
Scene scene = new Scene(root, 600, 600);
primaryStage.setScene(scene);
primaryStage.show();

代码示例来源:origin: stackoverflow.com

final Label lblTool = new Label();
HBox hBox = new HBox();
hBox.setSpacing(5.0);
hBox.setPadding(new Insets(5, 5, 5, 5));
hBox.getChildren().add(lblTool);
    lblTool.setText(newValue.getTool());
BorderPane pane = new BorderPane();
pane.setTop(hBox);
pane.setCenter(table);
stage.setScene(new Scene(pane, 640, 480));
stage.show();

代码示例来源:origin: stackoverflow.com

tabPane.getTabs().add(createTab());
Button addTabButton = new Button( "Add Tab");
addTabButton.setOnAction(e -> {
  tabPane.getTabs().add(createTab());
});
Button logButton = new Button( "Log");
logButton.setOnAction(e -> {
  for( Tab tab: tabPane.getTabs()) {
HBox toolbar = new HBox();
HBox.setMargin(addTabButton, new Insets(5,5,5,5));
HBox.setMargin(logButton, new Insets(5,5,5,5));
toolbar.getChildren().addAll( addTabButton, logButton);
BorderPane root = new BorderPane();
root.setTop(toolbar);
root.setCenter(tabPane);
primaryStage.setScene(scene);
primaryStage.show();
tab.setTooltip( new Tooltip( "Tooltip Tab " + tabCount));
Node content = new Label( "Content Tab " + tabCount);
tab.setContent(content);

代码示例来源:origin: stackoverflow.com

BorderPane settings = new BorderPane();
settings.setPadding(new Insets(10));
Button playBtn = new Button("Play");
Label zombieLabel = new Label("Zombie Dice");
zombieLabel.setStyle("-fx-font-size: 60");
zombieLabel.setAlignment(Pos.CENTER);
HBox zomBox = new HBox();
zomBox.getChildren().add(zombieLabel);
zomBox.setAlignment(Pos.CENTER);
Label indicateLabel = new Label("Indicate who is playing");
gridPane.setPadding(new Insets(5));
gridPane.setHgap(5);
gridPane.setVgap(5);
stage.setScene(root);
stage.show();

代码示例来源:origin: stackoverflow.com

choice.getSelectionModel().selectedItemProperty().addListener((obs, oldValue, newValue) -> line1.setLayoutX(newValue));
Button showValuesButton = new Button("Show all values");
showValuesButton.setOnAction(event -> {
  Stream.of(line1, line2).forEach(line -> {
    System.out.printf("Layout x,y: [%.1f, %.1f]%n", line.getLayoutX(), line.getLayoutY());
});
HBox controls = new HBox(5, new Label("Red layout x:"), choice, showValuesButton);
controls.setAlignment(Pos.CENTER);
controls.setPadding(new Insets(5));
BorderPane root = new BorderPane();
root.setCenter(pane);
root.setBottom(controls);
primaryStage.setScene(scene);
primaryStage.show();

代码示例来源:origin: stackoverflow.com

@Override
public void start(Stage primaryStage) {

  HBox hbox = new HBox();

  Button b = new Button("add");
  b.setOnAction(ev -> hbox.getChildren().add(new Label("Test")));

  ScrollPane scrollPane = new ScrollPane(hbox);
  scrollPane.setFitToHeight(true);

  BorderPane root = new BorderPane(scrollPane);
  root.setPadding(new Insets(15));
  root.setTop(b);

  Scene scene = new Scene(root, 400, 400);
  primaryStage.setScene(scene);
  primaryStage.show();
}

代码示例来源:origin: stackoverflow.com

HBox hbButtons = new HBox();
Button scrapeBtn = new Button();
scrapeBtn.setText("Scrape!");
scrapeBtn.setOnAction(new EventHandler<ActionEvent>() {
hbButtons .getChildren().add(scrapeBtn);
BorderPane root = new BorderPane();
root.setPadding(new Insets(20)); // space between elements and window border
root.setCenter(vbCenter);
root.setBottom(hbButtons);
primaryStage.setTitle("Wiki Scraper");
primaryStage.setScene(scene);
primaryStage.show();

代码示例来源:origin: stackoverflow.com

BorderPane root = new BorderPane();
Label label = new Label("Some\ntext");
label.setGraphic(new ImageView(getClass().getResource("/images/Folder-icon.png").toExternalForm()));
label.setMaxWidth(Double.POSITIVE_INFINITY);
label.setMaxHeight(Double.POSITIVE_INFINITY);
label.setStyle("-fx-border-color: blue;");
root.setCenter(label);
ctrls.setHgap(5);
ctrls.setVgap(5);
ctrls.setPadding(new Insets(10));
ctrls.addRow(0, new Label("Content display:"), new Label("Alignment:"), new Label("Text Alignment:"));
ctrls.addRow(1,  contentDisplayBox, alignmentBox, textAlignmentBox);
root.setTop(ctrls);
primaryStage.setScene(scene);
primaryStage.show();

代码示例来源:origin: stackoverflow.com

txtHeading.setFont(new Font(20));
HBox paneTop = new HBox(txtHeading);
paneTop.setPadding(new Insets(20, 20, 20, 20));
Button btn1 = new Button("Picture");
btn1.setPrefWidth(80);
pane.setPadding(new Insets(20, 20, 20, 20));
btn1.setOnAction(e -> btn1_Click(pane));
primaryStage.setScene(scene);
primaryStage.setTitle("Picture Choice");
primaryStage.show();
iview1.setPreserveRatio(true);
BorderPane bpane1 = new BorderPane();
bpane1.setCenter(iview1);
parent.getChildren().add(bpane1);

代码示例来源:origin: stackoverflow.com

TilePane tile = new TilePane();
root.setStyle("-fx-background-color: DAE6F3;");
tile.setPadding(new Insets(15, 15, 15, 15));
tile.setHgap(15);
root.setContent(tile);
primaryStage.setWidth(Screen.getPrimary().getVisualBounds().getWidth());
primaryStage.setHeight(Screen.getPrimary().getVisualBounds()
    .getHeight());
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.show();
            BorderPane borderPane = new BorderPane();
            ImageView imageView = new ImageView();
            Image image = new Image(new FileInputStream(imageFile));

代码示例来源:origin: stackoverflow.com

container.setAlignment(Pos.CENTER);
container.setPadding(new Insets(10));
BorderPane pane = new BorderPane();
pane.setCenter(container);
Scene scene = new Scene(pane, 150, 150);
primaryStage.setScene(scene);
primaryStage.show();

代码示例来源:origin: stackoverflow.com

BorderPane root = new BorderPane();
Button backButton = new Button("Back");
Button deleteButton = new Button("Delete");
Button showAllButton = new Button("Show All");
gridPane.setPadding(new Insets(2));
root.setBottom(gridPane);
Scene scene = new Scene(root, 600, 600);
primaryStage.setScene(scene);
primaryStage.show();

代码示例来源:origin: stackoverflow.com

public void start(Stage primaryStage) {

  ComboBox<String> combobox1 = new ComboBox<>();

  ComboBox<String> combobox2 = new ComboBox<>();
  combobox2.setDisable(true);
  combobox2.setStyle("-fx-opacity: 1;");

  BorderPane root = new BorderPane();
  root.setPadding(new Insets(15));

  root.setTop(combobox1);
  root.setBottom(combobox2);
  Scene scene = new Scene(root, 400, 400);
  primaryStage.setScene(scene);
  primaryStage.show();
}

代码示例来源:origin: stackoverflow.com

public class Main extends Application {

  @Override
  public void start(Stage primaryStage) {

    Canvas canvas = new Canvas(0, 0);
    Button button = new Button("test");
    button.setOnAction(ev -> {
      canvas.setWidth(canvas.getWidth() + 10);
      canvas.setHeight(canvas.getHeight() + 10);
      canvas.getGraphicsContext2D().clearRect(0, 0, canvas.getWidth(), canvas.getHeight());
      canvas.getGraphicsContext2D().fillRect(0, 0, canvas.getWidth(), canvas.getHeight());
    });

    BorderPane canvasBorderPane = new BorderPane(canvas);
    canvasBorderPane.setPadding(new Insets(10));
    canvasBorderPane.setBackground(new Background(new BackgroundFill(Color.RED, new CornerRadii(0), Insets.EMPTY)));

    BorderPane root = new BorderPane(canvasBorderPane);
    root.setPadding(new Insets(10));
    root.setBackground(new Background(new BackgroundFill(Color.BLUE, new CornerRadii(0), Insets.EMPTY)));
    root.setBottom(button);
    Scene scene = new Scene(root, 400, 400);
    primaryStage.setScene(scene);
    primaryStage.show();
  }
}

相关文章