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

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

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

VBox介绍

暂无

代码示例

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

primaryStage.setTitle("Extension Filter Example");
final Label fileLabel = new Label();
Button btn = new Button("Open FileChooser");
btn.setOnAction(new EventHandler<ActionEvent>() {
      fileLabel.setText(file.getPath());
VBox vBox = new VBox(30);
vBox.getChildren().addAll(fileLabel, btn);
vBox.setAlignment(Pos.BASELINE_CENTER);
primaryStage.setScene(new Scene(root, 300, 250));
primaryStage.show();

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

stage.setTitle("Tree View Sample");
VBox box = new VBox();
final Scene scene = new Scene(box, 400, 300);
scene.setFill(Color.LIGHTGRAY);
box.getChildren().addAll(new JFXTreeViewPath(treeView), treeView, filterField);
VBox.setVgrow(treeView, Priority.ALWAYS);
stage.setScene(scene);
stage.show();

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

VBox headerPanel = new VBox();
headerPanel.getStyleClass().add("month-year-pane");
headerPanel.setBackground(new Background(new BackgroundFill(this.datePicker.getDefaultColor(),
  CornerRadii.EMPTY,
  Insets.EMPTY)));
headerPanel.setPadding(new Insets(12, 24, 12, 24));
headerPanel.getChildren().add(yearLabelContainer);
headerPanel.getChildren().add(selectedDateContainer);
return headerPanel;

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

private VBox createStackedTitledPanes() {
 final VBox stackedTitledPanes = new VBox();
 stackedTitledPanes.getChildren().setAll(
  new TitledPane("Pane 1",  contentNode1),
  new TitledPane("Pane 2",  contentNode2),
  new TitledPane("Pane 3",  contentNode3)
 );
 ((TitledPane) stackedTitledPanes.getChildren().get(0)).setExpanded(true);

 return stackedTitledPanes;
}

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

Stage dialogStage = new Stage();
 dialogStage.initModality(Modality.WINDOW_MODAL);
 VBox vbox = new VBox(new Text("Hi"), new Button("Ok."));
 vbox.setAlignment(Pos.CENTER);
 vbox.setPadding(new Insets(15));
 dialogStage.setScene(new Scene(vbox));
 dialogStage.show();

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

public void setContent(Node content) {
  if (contentContainer.getChildren().size() == 2) {
    contentContainer.getChildren().set(1, content);
  } else if (contentContainer.getChildren().size() == 1) {
    contentContainer.getChildren().add(content);
  } else {
    contentContainer.getChildren().setAll(headerSpace, content);
  }
  VBox.setVgrow(content, Priority.ALWAYS);
}

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

public void start(Stage primaryStage) {
  final AtomicLong counter = new AtomicLong(-1);
  final Label label = new Label();
  final Thread countThread = new Thread(new Runnable() {
    @Override
  countThread.start();
  VBox root = new VBox();
  root.getChildren().add(label);
  root.setPadding(new Insets(5));
  root.setAlignment(Pos.CENTER);
  primaryStage.setScene(scene);
  primaryStage.show();

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

stage.setTitle("Table View Sample");
stage.setWidth(450);
stage.setHeight(500);
final Label label = new Label("Address Book");
label.setFont(new Font("Arial", 20));
table.getColumns().addAll(firstNameCol, lastNameCol, emailCol);
final VBox vbox = new VBox();
vbox.setSpacing(5);
vbox.setPadding(new Insets(10, 0, 0, 10));
vbox.getChildren().addAll(label, table);
stage.setScene(new Scene(new Group(vbox)));
stage.show();

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

Button button = new Button("Go!");
button.setOnAction(new EventHandler<ActionEvent>() {
  @Override public void handle(ActionEvent actionEvent) {
    task.playFromStart();
VBox layout = new VBox(10);
layout.getChildren().setAll(
  bar,
  button
);
layout.setPadding(new Insets(10));
layout.setAlignment(Pos.CENTER);
layout.getStylesheets().add(
  getClass().getResource(
    "striped-progress.css"
);
stage.setScene(new Scene(layout));
stage.show();

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

stage.setTitle("Table View Sample");
final Label label = new Label("Address Book");
label.setFont(new Font("Arial", 20));
final Label actionTaken = new Label();
  return new TableCell<Person, Person>() {
   final ImageView buttonGraphic = new ImageView();
   final Button button = new Button(); {
    button.setGraphic(buttonGraphic);
    button.setMinWidth(130);
table.getColumns().addAll(firstNameCol, lastNameCol, emailCol, btnCol);
final VBox vbox = new VBox();
vbox.setSpacing(5);
vbox.setPadding(new Insets(10, 10, 10, 10));
vbox.getChildren().addAll(label, table, actionTaken);
VBox.setVgrow(table, Priority.ALWAYS);
stage.setScene(new Scene(vbox));
stage.show();

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

@Override
public void start(Stage stage) throws Exception {
  final VBox pane = new VBox();
  pane.setSpacing(30);
  pane.setStyle("-fx-background-color:#EEE; -fx-padding: 40;");
  ToggleButton button = new ToggleButton("JavaFx Toggle");
  pane.getChildren().add(button);
  JFXToggleButton toggleButton = new JFXToggleButton();
  toggleButton.setText("New Skin");
  pane.getChildren().add(toggleButton);
  JFXToggleNode node = new JFXToggleNode();
  final GlyphIcon heartIcon = GlyphsBuilder.create(FontAwesomeIconView.class)
    .glyph(FontAwesomeIcon.HEART)
    .build();
  heartIcon.setStyle("-fx-padding: 10");
  node.setGraphic(heartIcon);
  pane.getChildren().add(node);
  final Scene scene = new Scene(pane, 600, 400, Color.valueOf("#EEE"));
  stage.setTitle("JFX Toggle Button Demo ");
  scene.getStylesheets()
    .add(ToggleButtonDemo.class.getResource("/css/jfoenix-components.css").toExternalForm());
  stage.setScene(scene);
  stage.setResizable(false);
  stage.show();
}

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

Button btn = new Button();
btn.setText("Choose favorite meal");
Label label = new Label("I don't know your favorite meal yet!");
btn.setOnAction((ActionEvent event) -> {
  FXMLLoader loader = new FXMLLoader(getClass().getResource("input.fxml"));
  Scene newScene;
  Stage inputStage = new Stage();
  inputStage.initOwner(primaryStage);
  inputStage.setScene(newScene);
  inputStage.showAndWait();
  label.setText(meal == null ? "C'mon, tell me your favourite meal already!" : "Your favourite meal is "+meal+". Interesting!");
});
root.setSpacing(10);
root.setPadding(new Insets(10));
root.setPrefWidth(300);

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

VBox vbCenter = new VBox(); // use any container as center pane e.g. VBox
TextField console = new TextField();
vbCenter.getChildren().add(console);
Button scrapeBtn = new Button();
scrapeBtn.setText("Scrape!");
scrapeBtn.setOnAction(new EventHandler<ActionEvent>() {
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

public class Demo extends Application {

  @Override
  public void start(Stage stage) {
    Group root = new Group();
    Scene scene = new Scene(root);
    stage.setScene(scene);

    TextField myTextField = new TextField("default");
    Rectangle myRectangle = new Rectangle();
    myRectangle.setHeight(30);
    myRectangle.setFill(Color.AQUA);
    myRectangle.widthProperty().bind(myTextField.widthProperty());

    final VBox hb = new VBox(10);
    hb.setPadding(new Insets(5));
    hb.getChildren().addAll(myTextField, myRectangle);
    scene.setRoot(hb);
    stage.show();
  }

  public static void main(String[] args) {
    launch(args);
  }
}

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

public class Main extends Application {
  @Override
  public void start(Stage stage) {        
    final VBox vbox = new VBox();
    vbox.setSpacing(5);
    vbox.setPadding(new Insets(10, 0, 0, 10));

    final TextField textField = new TextField();
    final Button button = new Button();

    vbox.getChildren().addAll(textField, button);

    vbox.onKeyPressedProperty().set(new EventHandler<KeyEvent>() {
      @Override public void handle(KeyEvent event) {
        textField.requestFocus();
      }
    });

    stage.setScene(new Scene(vbox, 300, 500));
    stage.show();
  }

  public static void main(String[] args) {
    launch(args);
  }
}

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

Keyboard keyboard = new Keyboard();
VBox layout = new VBox(20);
layout.setPadding(new Insets(10));
layout.getChildren().setAll(
    createControls(keyboard),
scene.getStylesheets().add(
    getClass().getResource(
        "keyboard.css"
);
stage.setScene(scene);
stage.show();
fontSize.setMinorTickCount(0);
Label typedData = new Label();
keyboard.lastKeyTextProperty().addListener((observable, oldText, newText) ->
    typedData.setText(typedData.getText() + newText)
);
VBox layout = new VBox(10);
layout.getChildren().setAll(
    new Label("Keyboard Size"),

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

Button button = new Button("Choose");
Label chosen = new Label();
button.setOnAction(event -> {
  FileChooser chooser = new FileChooser();
  File file = chooser.showOpenDialog(stage);
    String fileAsString = file.toString();
    chosen.setText("Chosen: " + fileAsString);
  } else {
    chosen.setText(null);
layout.setMinWidth(400);
layout.setAlignment(Pos.CENTER);
layout.setPadding(new Insets(10));
stage.setScene(new Scene(layout));
stage.show();

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

HBox timeSpinner = loader.load();
TimeSpinnerController timeController = loader.getController() ;
Label label = new Label();
label.textProperty().bind(Bindings.createStringBinding(() -> {
  long s = timeController.getTime().getSeconds() ;
  return String.format("%02d:%02d:%02d", s / 3600, (s / 60) % 60, s % 60);
root.setAlignment(Pos.CENTER);
root.setPadding(new Insets(24));
primaryStage.setScene(new Scene(root));
primaryStage.show();

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

@Override
 public void start(Stage primaryStage) throws Exception{
   TextField textfield = new TextField();
   ListView listView = new ListView();
   listView.getItems().add("One");
   listView.getItems().add("Two");
   listView.getItems().add("Three");
   Button button = new Button("Button");
   VBox root = new VBox(5, textfield, listView, button);
   root.addEventFilter(KeyEvent.KEY_PRESSED, event->{
     if (event.getCode() == KeyCode.SPACE) {
       System.out.println("GOOD");
     }
   });
   root.setAlignment(Pos.CENTER);
   root.setPadding(new Insets(10));
   primaryStage.setScene(new Scene(root, 400, 400));
   primaryStage.show();
 }

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

@Override
public void start(Stage primaryStage) {
  Button btn = new Button();
  btn.setText("Say 'Hello World'");
  btn.setOnAction(e -> System.out.println("Hello World!"));

  VBox box = new VBox(btn);
  box.getStyleClass().add("box");

  StackPane root = new StackPane();
  root.setPadding(new Insets(20));
  root.getChildren().add(box);

  Scene scene = new Scene(root, 300, 250);
  scene.getStylesheets().add(getClass().getResource("style.css").toExternalForm());

  primaryStage.setTitle("Hello World!");
  primaryStage.setScene(scene);
  primaryStage.show();

  Region node = (Region) root.lookup(".box");
  if (node != null) {
    Image image = node.getBackground().getImages().get(0).getImage();
    System.out.println("Image " + image);
  }
}

相关文章