Package javafx.scene.layout

Examples of javafx.scene.layout.VBox


  }
 
  private void initialiseProblemTypeParameters(final JCGP jcgp, final GUI gui) {
    updateArity();
   
    problemPane= new VBox(2);
   
    Text header = new Text("Problem Type");
    header.setFont(Font.font("Arial", 14));
    header.setUnderline(true);
   
    final ComboBox<Problem> problemCBox = new ComboBox<Problem>();
    problemCBox.getItems().addAll(jcgp.getProblems());
    problemCBox.getSelectionModel().select(jcgp.getProblem());
    problemCBox.prefWidthProperty().bind(mainContainer.widthProperty());
   
    final VBox problemParameters = new VBox(2);
    problemParameters.setPadding(new Insets(0, 0, 4, 0));
    refreshParameters(jcgp.getProblem().getLocalParameters(), problemParameters);
   
    final HBox testCaseControlContainer = new HBox(2);
   
    final Button showTestCaseButton = makeTestCaseButton();
    final Button loadProblemDataButton = makeLoadTestCaseButton();
    HBox.setHgrow(showTestCaseButton, Priority.ALWAYS);
    showTestCaseButton.setMaxWidth(Double.MAX_VALUE);
    HBox.setHgrow(loadProblemDataButton, Priority.ALWAYS);
    loadProblemDataButton.setMaxWidth(Double.MAX_VALUE);
   
    if (jcgp.getProblem() instanceof TestCaseProblem<?>) {
      testCaseControlContainer.getChildren().addAll(showTestCaseButton, loadProblemDataButton);
      remakeTestCaseTable();
    } else {
      testCaseControlContainer.getChildren().add(loadProblemDataButton);
    }
   
    nodeFunctions = new VBox(2);
    nodeFunctions.setPadding(new Insets(0, 0, 4, 0));
    refreshFunctions();
   
    problemCBox.setOnAction(new EventHandler<ActionEvent>() {
      @Override
View Full Code Here


  private void createControls(final GUI gui) {
    Text header = new Text("Experiment controls");
    header.setFont(Font.font("Arial", 14));
    header.setUnderline(true);
   
    final VBox controls = new VBox(2);
    controls.setFillWidth(true);
   
    final HBox flowButtons = new HBox(2);
    runPause.setOnAction(new EventHandler<ActionEvent>() {
      @Override
      public void handle(ActionEvent event) {       
        gui.runPause();
      }
    });
   
    step.setOnAction(new EventHandler<ActionEvent>() {
      @Override
      public void handle(ActionEvent event) {
        gui.step();
      }
    });
   
    reset.setOnAction(new EventHandler<ActionEvent>() {
      @Override
      public void handle(ActionEvent event) {
        gui.reset();
      }
    });
   
    HBox.setHgrow(runPause, Priority.ALWAYS);
    runPause.setMaxWidth(Double.MAX_VALUE);
    HBox.setHgrow(step, Priority.ALWAYS);
    step.setMaxWidth(Double.MAX_VALUE);
    HBox.setHgrow(reset, Priority.ALWAYS);
    reset.setMaxWidth(Double.MAX_VALUE);
   
    flowButtons.getChildren().addAll(runPause, step, reset);
    flowButtons.setPadding(new Insets(0, 0, 10, 0));
   
    loadParameters.setOnAction(new EventHandler<ActionEvent>() {
      @Override
      public void handle(ActionEvent event) {       
        FileChooser fc = new FileChooser();
        fc.setTitle("Open .par file...");
        fc.getExtensionFilters().add(new ExtensionFilter("CGP parameter files", "*.par"));
        fc.getExtensionFilters().add(new ExtensionFilter("All files", "*.*"));
        File parFile = fc.showOpenDialog(gui.getStage());
        if (parFile != null) {
          gui.getExperiment().loadParameters(parFile);
          gui.reDraw();
          refreshFunctions();
        }
        gui.flushConsole();
      }
    });
   
    loadChromosome.setOnAction(new EventHandler<ActionEvent>() {
      @Override
      public void handle(ActionEvent event) {
        FileChooser fc = new FileChooser();
        fc.setTitle("Load .chr file...");
        fc.getExtensionFilters().add(new ExtensionFilter("CGP chromosome files", "*.chr"));
        fc.getExtensionFilters().add(new ExtensionFilter("All files", "*.*"));
        File chrFile = fc.showOpenDialog(gui.getStage());
        if (chrFile != null) {
          gui.getExperiment().loadChromosome(chrFile, gui.getChromosomeIndex());
          gui.reDraw();
        }
        gui.flushConsole();
      }
    });
    saveChromosome.setOnAction(new EventHandler<ActionEvent>() {
      @Override
      public void handle(ActionEvent event) {
        FileChooser fc = new FileChooser();
        fc.setTitle("Save .chr file...");
        fc.getExtensionFilters().add(new ExtensionFilter("CGP chromosome files", "*.chr"));
        fc.getExtensionFilters().add(new ExtensionFilter("All files", "*.*"));
        File chrFile = fc.showSaveDialog(gui.getStage());
        if (chrFile != null) {
          gui.getExperiment().saveChromosome(chrFile, gui.getChromosomeIndex());
        }
        gui.flushConsole();
      }
    });
   
    HBox.setHgrow(loadParameters, Priority.ALWAYS);
    loadParameters.setMaxWidth(Double.MAX_VALUE);
    HBox.setHgrow(loadChromosome, Priority.ALWAYS);
    loadChromosome.setMaxWidth(Double.MAX_VALUE);
    HBox.setHgrow(saveChromosome, Priority.ALWAYS);
    saveChromosome.setMaxWidth(Double.MAX_VALUE);
   
    controls.getChildren().addAll(header, flowButtons, loadParameters, loadChromosome, saveChromosome);
   
    mainContainer.getChildren().add(controls)
  }
View Full Code Here

    final ImageView background = new ImageView();
    background.setOpacity(0.3);
    background.setImage(Assets.getBackground(Assets.IMAGE_SCREENS_GAME_SELECTION_BACKGROUND));

    VBox vbox = new VBox();
    vbox.setAlignment(Pos.CENTER);
    vbox.setSpacing(15);
    vbox.setPadding(new Insets(25, 25, 25, 25));

    Label label = new Label("Enter your name Player " + (position + 1));
    label.setFont(Assets.getFont(Assets.FONT_COURIERNEW_BOLD_16));
    label.setTextFill(Color.LIGHTGRAY);

    final TextField name = new TextField();
    name.setPrefColumnCount(15);
    name.setText("Player " + (position + 1));
    name.setOnAction(new EventHandler<ActionEvent>() {
      @Override
      public void handle(ActionEvent e) {
        player.setName(name.getText());
        name.setDisable(true);
        genesia.askNextPlayerName(position + 1);
      }
    });

    vbox.getChildren().addAll(label, name);

    getChildren().addAll(backgroundRect, background, vbox);
  }
View Full Code Here

    backgroundRect.setHeight(400);

    final FadeTransition fadeInSelection = new FadeTransition(Duration.millis(500));
    final FadeTransition fadeOutBackground = new FadeTransition(Duration.millis(1000));

    final VBox outerPane = new VBox();
    outerPane.setAlignment(Pos.CENTER);
    outerPane.setVisible(false);
    outerPane.setOpacity(0.0);
    outerPane.setPadding(new Insets(0, 15, 0, 15));
    outerPane.setSpacing(20);

    final ImageView background = new ImageView();
    background.setCursor(Cursor.HAND);
    background.setOpacity(1.0);
    background.setImage(Assets.getBackground(Assets.IMAGE_SCREENS_GAME_SELECTION_BACKGROUND));
    background.setOnMouseClicked(new EventHandler<MouseEvent>() {
      @Override
      public void handle(MouseEvent me) {
        if (!outerPane.isVisible()) {
          background.setCursor(null);
          outerPane.setVisible(true);
          fadeInSelection.play();
          fadeOutBackground.play();
        }
      }
    });

    fadeInSelection.setCycleCount(1);
    fadeInSelection.setFromValue(1.0);
    fadeInSelection.setToValue(0.3);
    fadeInSelection.setNode(background);
    fadeOutBackground.setCycleCount(1);
    fadeOutBackground.setFromValue(0.0);
    fadeOutBackground.setToValue(1.0);
    fadeOutBackground.setNode(outerPane);

    Label numberOfPlayersLabel = new Label("NUMBER OF PLAYERS");
    numberOfPlayersLabel.setFont(Assets.getFont(Assets.FONT_COURIERNEW_BOLD_16));
    numberOfPlayersLabel.setTextFill(Color.LIGHTGRAY);

    numberOfPlayers = new ToggleGroup();

    RadioButton numberOfPlayers1 = new RadioButton("1");
    numberOfPlayers1.setFont(Assets.getFont(Assets.FONT_COURIERNEW_BOLD_13));
    numberOfPlayers1.setSelected(true);
    numberOfPlayers1.setUserData(1);
    numberOfPlayers1.setToggleGroup(numberOfPlayers);
    numberOfPlayers1.setMinWidth(120);
    numberOfPlayers1.setMaxWidth(120);

    RadioButton numberOfPlayers2 = new RadioButton("2");
    numberOfPlayers2.setFont(Assets.getFont(Assets.FONT_COURIERNEW_BOLD_13));
    numberOfPlayers2.setUserData(2);
    numberOfPlayers2.setToggleGroup(numberOfPlayers);
    numberOfPlayers2.setMinWidth(120);
    numberOfPlayers2.setMaxWidth(120);

    RadioButton numberOfPlayers3 = new RadioButton("3");
    numberOfPlayers3.setFont(Assets.getFont(Assets.FONT_COURIERNEW_BOLD_13));
    numberOfPlayers3.setUserData(3);
    numberOfPlayers3.setToggleGroup(numberOfPlayers);

    HBox numberOfPlayersButtons = new HBox();
    numberOfPlayersButtons.setAlignment(Pos.CENTER);
    numberOfPlayersButtons.getChildren().addAll(numberOfPlayers1,
            numberOfPlayers2, numberOfPlayers3);

    Line horizontalLine1 = new Line();
    horizontalLine1.setEndX(480);
    horizontalLine1.setStroke(Color.GRAY);
    horizontalLine1.setStrokeWidth(2);

    Label worldCreationLabel = new Label("CREATION OF THE WORLD");
    worldCreationLabel.setFont(Assets.getFont(Assets.FONT_COURIERNEW_BOLD_16));
    worldCreationLabel.setTextFill(Color.LIGHTGRAY);

    worldCreation = new ToggleGroup();

    RadioButton worldCreation1 = new RadioButton("1");
    worldCreation1.setFont(Assets.getFont(Assets.FONT_COURIERNEW_BOLD_13));
    worldCreation1.setSelected(true);
    worldCreation1.setUserData(new FlatLandWorldGenerator(0.15));
    worldCreation1.setToggleGroup(worldCreation);
    worldCreation1.setMinWidth(120);
    worldCreation1.setMaxWidth(120);

    RadioButton worldCreation2 = new RadioButton("2");
    worldCreation2.setFont(Assets.getFont(Assets.FONT_COURIERNEW_BOLD_13));
    worldCreation2.setUserData(new FlatLandWorldGenerator(0.3));
    worldCreation2.setToggleGroup(worldCreation);
    worldCreation2.setMinWidth(120);
    worldCreation2.setMaxWidth(120);

    RadioButton worldCreation3 = new RadioButton("3");
    worldCreation3.setFont(Assets.getFont(Assets.FONT_COURIERNEW_BOLD_13));
    worldCreation3.setUserData(new FlatLandWorldGenerator(0.45));
    worldCreation3.setToggleGroup(worldCreation);
    worldCreation3.setMinWidth(120);
    worldCreation3.setMaxWidth(120);

    RadioButton worldCreation4 = new RadioButton("4");
    worldCreation4.setFont(Assets.getFont(Assets.FONT_COURIERNEW_BOLD_13));
    worldCreation4.setUserData(new FlatLandWorldGenerator(0.6));
    worldCreation4.setToggleGroup(worldCreation);
    worldCreation4.setMinWidth(120);
    worldCreation4.setMaxWidth(120);

    RadioButton worldCreation5 = new RadioButton("5");
    worldCreation5.setFont(Assets.getFont(Assets.FONT_COURIERNEW_BOLD_13));
    worldCreation5.setUserData(new FlatLandWorldGenerator(0.75));
    worldCreation5.setToggleGroup(worldCreation);

    HBox worldCreationButtons = new HBox();
    worldCreationButtons.setAlignment(Pos.CENTER);
    worldCreationButtons.getChildren().addAll(worldCreation1, worldCreation2,
            worldCreation3, worldCreation4, worldCreation5);

    Line horizontalLine2 = new Line();
    horizontalLine2.setEndX(480);
    horizontalLine2.setStroke(Color.GRAY);
    horizontalLine2.setStrokeWidth(2);

    Label gameLevelLabel = new Label("GAME LEVEL");
    gameLevelLabel.setFont(Assets.getFont(Assets.FONT_COURIERNEW_BOLD_16));
    gameLevelLabel.setTextFill(Color.LIGHTGRAY);

    gameLevel = new ToggleGroup();

    RadioButton gameLevel1 = new RadioButton("BEGINNER");
    gameLevel1.setFont(Assets.getFont(Assets.FONT_COURIERNEW_BOLD_13));
    gameLevel1.setUserData(Game.Difficulty.BEGINNER);
    gameLevel1.setToggleGroup(gameLevel);
    gameLevel1.setMinWidth(120);
    gameLevel1.setMaxWidth(120);

    RadioButton gameLevel2 = new RadioButton("NORMAL");
    gameLevel2.setFont(Assets.getFont(Assets.FONT_COURIERNEW_BOLD_13));
    gameLevel2.setSelected(true);
    gameLevel2.setUserData(Game.Difficulty.NORMAL);
    gameLevel2.setToggleGroup(gameLevel);
    gameLevel2.setMinWidth(120);
    gameLevel2.setMaxWidth(120);

    RadioButton gameLevel3 = new RadioButton("ADVANCED");
    gameLevel3.setFont(Assets.getFont(Assets.FONT_COURIERNEW_BOLD_13));
    gameLevel3.setUserData(Game.Difficulty.ADVANCED);
    gameLevel3.setToggleGroup(gameLevel);

    HBox gameLevelButtons = new HBox();
    gameLevelButtons.setAlignment(Pos.CENTER);
    gameLevelButtons.getChildren().addAll(gameLevel1, gameLevel2, gameLevel3);

    Button startNewGame = new Button("NEW GAME");
    VBox.setMargin(startNewGame, new Insets(25, 0, 0, 0));
    startNewGame.setFont(Assets.getFont(Assets.FONT_COURIERNEW_BOLD_16));
    startNewGame.setCursor(Cursor.HAND);
    startNewGame.setOnAction(new EventHandler<ActionEvent>() {
      @Override
      public void handle(ActionEvent ae) {
        Game game = new Game();
        game.setDifficulty((Game.Difficulty) gameLevel.getSelectedToggle().getUserData());

        int totalPlayers = (Integer) numberOfPlayers.getSelectedToggle().getUserData();
        for (int i = 0; i < totalPlayers; i++) {
          Player player = new Player();
          player.setComputer(false);
          player.setColor(Player.COLORS[i]);
          switch (game.getDifficulty()) {
            case BEGINNER:
              player.setGold(12000);
            case NORMAL:
              player.setGold(10000);
            case ADVANCED:
              player.setGold(8000);
          }
          game.getPlayers().add(player);
        }
        for (int i = totalPlayers; i < 3; i++) {
          Player player = new Player();
          player.setComputer(true);
          player.setColor(Player.COLORS[i]);
          player.setName(Player.NAMES[i - totalPlayers]);
          switch (game.getDifficulty()) {
            case BEGINNER:
              player.setGold(8000);
            case NORMAL:
              player.setGold(10000);
            case ADVANCED:
              player.setGold(12000);
          }
          game.getPlayers().add(player);
        }

        WorldGenerator worldGenerator = (WorldGenerator) worldCreation.getSelectedToggle().getUserData();
        game.setWorld(worldGenerator.generate(64, 256));

        genesia.setGame(game);
      }
    });

    outerPane.getChildren().addAll(numberOfPlayersLabel, numberOfPlayersButtons,
            horizontalLine1, worldCreationLabel, worldCreationButtons,
            horizontalLine2, gameLevelLabel, gameLevelButtons,
            startNewGame);

    getChildren().addAll(backgroundRect, background, outerPane);
View Full Code Here

    description.setFont(Assets.getFont(Assets.FONT_COURIERNEW_BOLD_13));

    tileNodeGroup = new StackPane();
    tileNodeGroup.setPrefHeight(128.0);

    VBox labels = new VBox();
    labels.setAlignment(Pos.CENTER);
    labels.getChildren().addAll(landName, description);

    getChildren().addAll(tileNodeGroup, labels);
  }
View Full Code Here

            }
        });
    }

    public static void setupStagesClass() {
        pane = new VBox();
        firstIdLabel = new Label("first");
        firstIdLabel.setId("firstId");
        secondIdLabel = new Label("second");
        secondIdLabel.setId("secondId");
        thirdClassLabel = new Label("third");
        thirdClassLabel.getStyleClass().add("thirdClass");
        invisibleNode = new Label("invisible");
        invisibleNode.setId("invisibleNode");
        invisibleNode.setVisible(false);
        pane.getChildren().setAll(firstIdLabel, secondIdLabel, thirdClassLabel, invisibleNode);

        otherPane = new VBox();
        otherSubPane = new VBox();
        subLabel = new Label("sub");
        subLabel.setId("subLabel");
        subLabel.getStyleClass().add("sub");
        subSubLabel = new Label("subSub");
        subSubLabel.setId("subSubLabel");
        subSubLabel.getStyleClass().add("sub");
        otherPane.getChildren().setAll(subLabel, otherSubPane);
        otherSubPane.getChildren().setAll(subSubLabel);

        twinPane = new VBox();
        visibleTwin = new Button("Twin");
        visibleTwin.setId("twin");
        invisibleTwin = new Button("Twin");
        invisibleTwin.setId("twin");
        invisibleTwin.setVisible(false);
View Full Code Here

        Application.launch(Demo.class, args);
    }

    @Override
    public void start(Stage stage) {
        VBox root = new VBox();
        root.setPadding(new Insets(10, 10, 10, 10));
        final DemoObject instance1 = new SubDemoObject();
        instance1.setName("John");
        instance1.setAge(18);
        final DemoObject instance2 = new SubDemoObject();
        instance2.setName("Julio");
        instance2.setAge(4);
        new ObjectPropertyObserver(instance1);
        new ObjectPropertyObserver(instance2);
        final FXForm fxForm = createFXForm();
        Scene scene = new Scene(root);
        scene.getStylesheets().add(Demo.class.getResource("style.css").toExternalForm());
        ChoiceBox<FXFormSkinFactory> skinChoiceBox = new ChoiceBox<FXFormSkinFactory>();
        skinChoiceBox.getItems().addAll(FXFormSkinFactory.DEFAULT_FACTORY, FXFormSkinFactory.INLINE_FACTORY);
        skinChoiceBox.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<FXFormSkinFactory>() {
            public void changed(ObservableValue<? extends FXFormSkinFactory> observableValue, FXFormSkinFactory fxFormSkin, FXFormSkinFactory fxFormSkin1) {
                fxForm.setSkin(fxFormSkin1.createSkin(fxForm));
            }
        });
        ChoiceBox<DemoObject> instanceChoiceBox = new ChoiceBox<DemoObject>();
        instanceChoiceBox.getItems().addAll(instance1, instance2);
        instanceChoiceBox.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<DemoObject>() {
            public void changed(ObservableValue<? extends DemoObject> observableValue, DemoObject demoObject, DemoObject demoObject1) {
                fxForm.setSource(demoObject1);
            }
        });
        instanceChoiceBox.selectionModelProperty().get().selectFirst();
        skinChoiceBox.selectionModelProperty().get().selectFirst();
        root.getChildren().addAll(skinChoiceBox, instanceChoiceBox, fxForm);
        stage.setScene(scene);
        stage.show();
        fxForm.addFilters(new ReorderFilter(new String[]{"age", "mail"}));
    }
View Full Code Here

    public static final String TEXT_FIELD = ".text-field";

  @Override
  protected Parent getRootNode() {
    return  new VBox(new TextField());
  }
View Full Code Here

    private static final String ID2 = "ID2";

    @Override
    protected Parent getRootNode() {
        ScrollPane sp = new ScrollPane();
        VBox vb = new VBox();
        sp.setContent(vb);
        sp.setVmax(IMAGE_HEIGHT * 2);
        ImageView img1 = new ImageView(new Image(getClass()
                .getResourceAsStream(IMAGE_RESOURCE)));
        img1.setId(ID1);
        ImageView img2 = new ImageView(new Image(getClass()
                .getResourceAsStream(IMAGE_RESOURCE)));
        img2.setId(ID2);
        vb.getChildren().add(img1);
        vb.getChildren().add(img2);
        sp.setPrefWidth(IMAGE_WIDTH);
        sp.setPrefHeight(IMAGE_HEIGHT - 50);
        return sp;
    }
View Full Code Here

    @Override
    public Node getPanel(Stage stage) {
        final BorderPane bp = new BorderPane();
        Label title = new Label("Inline skin");
        VBox box = new VBox(10);
        ChoiceBox<String> choiceBox = new ChoiceBox<>();
        User user = new User();

        bp.setStyle("-fx-padding: 10;");
        choiceBox.getItems().addAll("Inline skin", "Default skin");
        bp.setTop(choiceBox);
        title.setFont(Font.font(24));

        FXForm form = new FXFormBuilder<>()
                .includeAndReorder("firstName", "lastName", "age", "favoriteMovie", "coolDeveloper")
                .resourceBundle(Utils.SAMPLE)
                .build();
        form.setSource(user);
        box.getChildren().addAll(title, form);
        choiceBox.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
            @Override
            public void changed(ObservableValue<? extends String> observableValue, String s, String s2) {
                if (s2.equals("Inline skin")) {
                    title.setText("Inline skin");
View Full Code Here

TOP

Related Classes of javafx.scene.layout.VBox

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.