当前位置: 首页>>代码示例>>Java>>正文


Java GridPane.setConstraints方法代码示例

本文整理汇总了Java中javafx.scene.layout.GridPane.setConstraints方法的典型用法代码示例。如果您正苦于以下问题:Java GridPane.setConstraints方法的具体用法?Java GridPane.setConstraints怎么用?Java GridPane.setConstraints使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.scene.layout.GridPane的用法示例。


在下文中一共展示了GridPane.setConstraints方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setupDispoGrid

import javafx.scene.layout.GridPane; //导入方法依赖的package包/类
private void setupDispoGrid() {
    dispoRegion = new Region[32][32];
    for (int y = 0; y < 32; y++) {
        dispoGrid.getColumnConstraints().get(y).setFillWidth(true);
        dispoGrid.getRowConstraints().get(y).setFillHeight(true);
        for (int x = 0; x < 32; x++) {
            Region region = new Region();
            region.setMinSize(5.0, 5.0);
            region.setId("dispoGrid");
            region.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
            dispoRegion[x][y] = region;
            dispoGrid.getChildren().add(region);
            GridPane.setConstraints(region, x, y);

            int yCoord = y;
            int xCoord = x;
            region.setOnMouseClicked(event -> moveBlock(xCoord, yCoord));
        }
    }
}
 
开发者ID:thane98,项目名称:FEFEditor,代码行数:21,代码来源:Dispo.java

示例2: WebViewPane

import javafx.scene.layout.GridPane; //导入方法依赖的package包/类
public WebViewPane() {
    VBox.setVgrow(this, Priority.ALWAYS);
    setMaxWidth(Double.MAX_VALUE);
    setMaxHeight(Double.MAX_VALUE);

    WebView view = new WebView();
    view.setMinSize(500, 400);
    view.setPrefSize(500, 400);
    final WebEngine eng = view.getEngine();
    eng.load("http://www.oracle.com/us/index.html");
    final TextField locationField = new TextField("http://www.oracle.com/us/index.html");
    locationField.setMaxHeight(Double.MAX_VALUE);
    Button goButton = new Button("Go");
    goButton.setDefaultButton(true);
    EventHandler<ActionEvent> goAction = new EventHandler<ActionEvent>() {
        @Override public void handle(ActionEvent event) {
            eng.load(locationField.getText().startsWith("http://") ? locationField.getText() :
                    "http://" + locationField.getText());
        }
    };
    goButton.setOnAction(goAction);
    locationField.setOnAction(goAction);
    eng.locationProperty().addListener(new ChangeListener<String>() {
        @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            locationField.setText(newValue);
        }
    });
    GridPane grid = new GridPane();
    grid.setVgap(5);
    grid.setHgap(5);
    GridPane.setConstraints(locationField, 0, 0, 1, 1, HPos.CENTER, VPos.CENTER, Priority.ALWAYS, Priority.SOMETIMES);
    GridPane.setConstraints(goButton,1,0);
    GridPane.setConstraints(view, 0, 1, 2, 1, HPos.CENTER, VPos.CENTER, Priority.ALWAYS, Priority.ALWAYS);
    grid.getColumnConstraints().addAll(
            new ColumnConstraints(100, 100, Double.MAX_VALUE, Priority.ALWAYS, HPos.CENTER, true),
            new ColumnConstraints(40, 40, 40, Priority.NEVER, HPos.CENTER, true)
    );
    grid.getChildren().addAll(locationField, goButton, view);
    getChildren().add(grid);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:41,代码来源:WebViewBrowser.java

示例3: start

import javafx.scene.layout.GridPane; //导入方法依赖的package包/类
@Override public void start(final Stage stage) {
    stage.setTitle("Directory Chooser Sample");

    final DirectoryChooser directoryChooser = new DirectoryChooser();
    final Button openButton = new Button("Select a folder...");

    openButton.setOnAction((final ActionEvent e) -> {
        File file = directoryChooser.showDialog(stage);
        if (file != null) {
            openFile(file);
        }
    });

    final GridPane inputGridPane = new GridPane();

    GridPane.setConstraints(openButton, 0, 1);
    inputGridPane.setHgap(6);
    inputGridPane.setVgap(6);
    inputGridPane.getChildren().addAll(openButton);

    final Pane rootGroup = new VBox(12);
    rootGroup.getChildren().addAll(inputGridPane);
    rootGroup.setPadding(new Insets(12, 12, 12, 12));

    stage.setScene(new Scene(rootGroup));
    stage.show();
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:28,代码来源:DirectoryChooserSample.java

示例4: initialize

import javafx.scene.layout.GridPane; //导入方法依赖的package包/类
private void initialize() {

        basePicker = new ColorPopupEditor(PaintPicker.Mode.SINGLE, Color.GAINSBORO);
        basePicker.setPrefWidth(200);

        desiredPicker = new ColorPopupEditor(PaintPicker.Mode.SINGLE, Color.DEEPSKYBLUE);
        desiredPicker.setPrefWidth(200);

        basePicker.getRectangle().fillProperty().addListener(o ->    updateForwardDerivation());
        desiredPicker.getRectangle().fillProperty().addListener(o -> updateReverseDerivation());
        derivationSlider.valueProperty().addListener(o ->            updateForwardDerivation());

        GridPane.setConstraints(basePicker,    4, 1);
        GridPane.setConstraints(desiredPicker, 4, 5);
        gridPane.getChildren().addAll(basePicker, desiredPicker);
    }
 
开发者ID:EricCanull,项目名称:fxexperience2,代码行数:17,代码来源:DerivationController.java

示例5: setupGrid

import javafx.scene.layout.GridPane; //导入方法依赖的package包/类
private void setupGrid() {
    tileLabels = new Label[32][32];
    for (int y = 0; y < 32; y++) {
        gridPane.getColumnConstraints().get(y).setFillWidth(true);
        gridPane.getRowConstraints().get(y).setFillHeight(true);
        for (int x = 0; x < 32; x++) {
            Label label = new Label();
            label.setMinSize(5.0, 5.0);
            label.setText(file.getMap()[x][y] + "");
            label.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
            label.setId(label.getText().equals("0") ? "inactiveTile" : "activeTile");
            tileLabels[x][y] = label;
            gridPane.getChildren().add(label);
            GridPane.setConstraints(label, x, y);

            int coordX = x;
            int coordY = y;
            label.setOnMouseClicked(event -> setTile(coordX, coordY));
        }
    }
}
 
开发者ID:thane98,项目名称:FEFEditor,代码行数:22,代码来源:Terrain.java

示例6: createSideBar

import javafx.scene.layout.GridPane; //导入方法依赖的package包/类
private Node createSideBar(ObservableList<SamplePage> relatedSamples) {
    GridPane sidebar = new GridPane() {
        // stretch to allways fill height of scrollpane
        @Override protected double computePrefHeight(double width) {
            return Math.max(
                    super.computePrefHeight(width),
                    getParent().getBoundsInLocal().getHeight()
            );
        }
    };
    sidebar.getStyleClass().add("right-sidebar");
    sidebar.setMaxWidth(Double.MAX_VALUE);
    sidebar.setMaxHeight(Double.MAX_VALUE);
    int sideRow = 0;
    // create side bar content
    // description
    Label discTitle = new Label("Related Samples");
    discTitle.getStyleClass().add("right-sidebar-title");
    GridPane.setConstraints(discTitle, 0, sideRow++);
    sidebar.getChildren().add(discTitle);
    // add sample tiles
    for (SamplePage sp: relatedSamples) {
        Node tile = sp.createTile();
        GridPane.setConstraints(tile, 0, sideRow++);
        sidebar.getChildren().add(tile);
    }
    return sidebar;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:29,代码来源:DocPage.java

示例7: ProxyPanel

import javafx.scene.layout.GridPane; //导入方法依赖的package包/类
public ProxyPanel() {
    setPadding(new Insets(8));
    setHgap(5.0F);
    setVgap(5.0F);

    int rowIndex = 0;

    Label label2 = new Label("Host Name");
    label2.setId("proxy-dialog-label");
    GridPane.setConstraints(label2, 0, rowIndex);

    Label label3 = new Label("Port");
    label3.setId("proxy-dialog-label");
    GridPane.setConstraints(label3, 1, rowIndex);
    getChildren().addAll(label2, label3);

    rowIndex++;
    hostNameBox = new TextField();
    hostNameBox.setPromptText("proxy.mycompany.com");
    hostNameBox.setPrefColumnCount(20);
    GridPane.setConstraints(hostNameBox, 0, rowIndex);

    portBox = new TextField();
    portBox.setPromptText("8080");
    portBox.setPrefColumnCount(10);
    GridPane.setConstraints(portBox, 1, rowIndex);

    ChangeListener<String> textListener = new ChangeListener<String>() {
        public void changed(ObservableValue<? extends String> ov, String t, String t1) {
            okBtn.setDisable(
                    hostNameBox.getText() == null || hostNameBox.getText().isEmpty()
                    || portBox.getText() == null || portBox.getText().isEmpty());
        }
    };
    hostNameBox.textProperty().addListener(textListener);
    portBox.textProperty().addListener(textListener);

    getChildren().addAll(hostNameBox, portBox);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:40,代码来源:ProxyDialog.java

示例8: LocalDirPanel

import javafx.scene.layout.GridPane; //导入方法依赖的package包/类
public LocalDirPanel() {
    setPadding(new Insets(8));
    setHgap(5.0F);
    setVgap(5.0F);

    int rowIndex = 0;
    Label parentDirLabel = new Label("Local javadoc index.html file");
    parentDirLabel.setId("parent-dir-label");
    GridPane.setConstraints(parentDirLabel, 0, rowIndex);
    getChildren().add(parentDirLabel);

    rowIndex++;
    textField = new TextField();
    textField.setEditable(false);
    GridPane.setConstraints(textField, 0, rowIndex,1,1, HPos.CENTER, VPos.CENTER, Priority.ALWAYS, Priority.NEVER);

    Button button = new Button("Browse...");
    button.setId("browseButton");
    button.setMinWidth(USE_PREF_SIZE);
    GridPane.setConstraints(button, 1, rowIndex);
    button.setOnAction(new EventHandler<ActionEvent>() {
        @Override public void handle(ActionEvent actionEvent) {
            FileChooser fileChooser = new FileChooser();
            fileChooser.setTitle("JavaFX 2.0 Javadoc location");
            FileChooser.ExtensionFilter filter = new FileChooser.ExtensionFilter("html", "*.html");
            fileChooser.getExtensionFilters().add(filter);
            File selectedFile = fileChooser.showOpenDialog(owner);
            
            okBtn.setDisable(selectedFile == null);
            if (selectedFile != null) {
                textField.setText(selectedFile.getAbsolutePath());
                docsUrl = selectedFile.toURI().toString();
                docsUrl = docsUrl.substring(0,docsUrl.lastIndexOf('/') + 1);
            }
        }
    });
    getChildren().addAll(textField, button);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:39,代码来源:ProxyDialog.java

示例9: ToggleButtonSample

import javafx.scene.layout.GridPane; //导入方法依赖的package包/类
public ToggleButtonSample() {
    // create label to show result of selected toggle button
    final Label label = new Label();
    label.setStyle("-fx-font-size: 2em;");
    // create 3 toggle buttons and a toogle group for them
    final ToggleButton tb1 = new ToggleButton("Cat");
    final ToggleButton tb2 = new ToggleButton("Dog");
    final ToggleButton tb3 = new ToggleButton("Horse");
    ToggleGroup group = new ToggleGroup();
    tb1.setToggleGroup(group);
    tb2.setToggleGroup(group);
    tb3.setToggleGroup(group);
    group.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {
        @Override public void changed(ObservableValue<? extends Toggle> observable, Toggle oldValue, Toggle selectedToggle) {
            if(selectedToggle!=null) {
                label.setText(((ToggleButton) selectedToggle).getText());
            }
            else {
                label.setText("...");
            }
        }
    });
    // select the first button to start with
    group.selectToggle(tb1);
    // add buttons and label to grid and set their positions
    GridPane.setConstraints(tb1,0,0);
    GridPane.setConstraints(tb2,1,0);
    GridPane.setConstraints(tb3,2,0);
    GridPane.setConstraints(label,0,1,3,1);
    GridPane grid = new GridPane();
    grid.setVgap(20);
    grid.setHgap(10);
    getChildren().add(grid);
    grid.getChildren().addAll(tb1, tb2, tb3, label);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:36,代码来源:ToggleButtonSample.java

示例10: initPlayer1Button

import javafx.scene.layout.GridPane; //导入方法依赖的package包/类
public void initPlayer1Button() {
    inventoryPlayer1.getChildren().remove(0, inventoryPlayer1.getChildren().size());
    List<Piece> inventory = core.getPlayers()[0].getInventory();
    int line = 0;
    int col = 0;
    for (int i = 0; i < inventory.size(); i++) {
        Piece piece = inventory.get(i);
        ToggleButton b = new ToggleButton();
        b.setMinSize(65, 65);
        b.setBackground(new Background(new BackgroundFill(new ImagePattern(piece.getImage()), CornerRadii.EMPTY, Insets.EMPTY)));


        if (core.getCurrentPlayer() == Consts.PLAYER1 && core.getState() == Consts.WAIT_FOR_INPUT) {
            b.setOnMouseClicked(new ControllerButtonPiece(this,inventory.get(i).getId(), i));
            //eventDragAndDropPiece(b,inventory.get(i).getId());
            b.getStyleClass().add("buttonInventory");
            b.setCursor(Cursor.HAND);
            b.setTooltip(new Tooltip(inventory.get(i).getDescription()));
            inventoryGroup.getToggles().add(b);
        }
        b.disableProperty().bind(animationPlaying);
        if (i != 0 && i % 4 == 0) {
            col = 0;
            line++;
        }
        GridPane.setConstraints(b, col, line);
        GridPane.setHalignment(b, HPos.CENTER);
        GridPane.setValignment(b, VPos.TOP);
        inventoryPlayer1.getChildren().add(b);
        col++;

    }
}
 
开发者ID:Plinz,项目名称:Hive_Game,代码行数:34,代码来源:GameScreenController.java

示例11: initPlayer2Button

import javafx.scene.layout.GridPane; //导入方法依赖的package包/类
public void initPlayer2Button() {
    inventoryPlayer2.getChildren().remove(0, inventoryPlayer2.getChildren().size());
    List<Piece> inventory = core.getPlayers()[1].getInventory();
    int line = 0;
    int col = 0;
    for (int i = 0; i < inventory.size(); i++) {
        Piece piece = inventory.get(i);
        ToggleButton b = new ToggleButton();
        b.setMinSize(65, 65);
        b.setBackground(new Background(new BackgroundFill(new ImagePattern(piece.getImage()), CornerRadii.EMPTY, Insets.EMPTY)));

        if (core.getCurrentPlayer() == Consts.PLAYER2 && core.getState() == Consts.WAIT_FOR_INPUT) {
            b.setOnMouseClicked(new ControllerButtonPiece(this,inventory.get(i).getId(), i));
            b.getStyleClass().add("buttonInventory");
            b.setCursor(Cursor.HAND);
            b.setTooltip(new Tooltip(inventory.get(i).getDescription()));
            inventoryGroup.getToggles().add(b);
        }
        b.disableProperty().bind(animationPlaying);

        if (i != 0 && i % 4 == 0) {
            col = 0;
            line++;
        }

        GridPane.setConstraints(b, col, line);
        GridPane.setHalignment(b, HPos.CENTER);
        GridPane.setValignment(b, VPos.TOP);
        inventoryPlayer2.getChildren().add(b);
        col++;
    }
}
 
开发者ID:Plinz,项目名称:Hive_Game,代码行数:33,代码来源:GameScreenController.java

示例12: initialize

import javafx.scene.layout.GridPane; //导入方法依赖的package包/类
/**
 * Initializes the controller class.
 */
public void initialize() {

    gradientPicker = new ColorPopupEditor(PaintPicker.Mode.COLOR, Color.web("#111111"));
    gradientPicker.setPrefWidth(200);
    GridPane.setConstraints(gradientPicker, 2, 3);
    gridPane.getChildren().add(gradientPicker);

    final ChangeListener<Paint> onPaintChanged = ((ov, oldValue, newValue) -> updateGradientCSS());
    gradientPicker.getRectangle().fillProperty().addListener(onPaintChanged);
}
 
开发者ID:EricCanull,项目名称:fxexperience2,代码行数:14,代码来源:GradientController.java

示例13: createSpineEditor

import javafx.scene.layout.GridPane; //导入方法依赖的package包/类
private void createSpineEditor() {

        SplineEditor = new SplineEditor();

        GridPane.setConstraints(SplineEditor, 0, 0, 1, 10,
                HPos.CENTER, VPos.CENTER, Priority.ALWAYS, Priority.ALWAYS);
        gridPane.add(SplineEditor, 0, 0);

        codeTextField.textProperty().bind(new StringBinding() {
            {
                bind(SplineEditor.controlPoint1xProperty(),
                        SplineEditor.controlPoint1yProperty(),
                        SplineEditor.controlPoint2xProperty(),
                        SplineEditor.controlPoint2yProperty());
            }

            @Override
            protected String computeValue() {
                return String.format("Interpolator.SPLINE(%.4f, %.4f, %.4f, %.4f);",
                        SplineEditor.getControlPoint1x(),
                        SplineEditor.getControlPoint1y(),
                        SplineEditor.getControlPoint2x(),
                        SplineEditor.getControlPoint2y());
            }
        });

        // create animation updater
        ChangeListener<Number> animUpdater = (ObservableValue<? extends Number> ov, Number t, Number t1) -> updateAnimation();

        SplineEditor.controlPoint1xProperty().addListener(animUpdater);
        SplineEditor.controlPoint1yProperty().addListener(animUpdater);
        SplineEditor.controlPoint2xProperty().addListener(animUpdater);
        SplineEditor.controlPoint2yProperty().addListener(animUpdater);
    }
 
开发者ID:EricCanull,项目名称:fxexperience2,代码行数:35,代码来源:SplineController.java

示例14: HTMLEditorSample

import javafx.scene.layout.GridPane; //导入方法依赖的package包/类
public HTMLEditorSample() {
    final VBox root = new VBox();
    root.setPadding(new Insets(8, 8, 8, 8));
    root.setSpacing(5);
    root.setAlignment(Pos.BOTTOM_LEFT);

    final GridPane grid = new GridPane();
    grid.setVgap(5);
    grid.setHgap(10);

    final ChoiceBox sendTo = new ChoiceBox(FXCollections.observableArrayList("To:", "Cc:", "Bcc:"));

    sendTo.setPrefWidth(100);
    GridPane.setConstraints(sendTo, 0, 0);
    grid.getChildren().add(sendTo);

    final TextField tbTo = new TextField();
    tbTo.setPrefWidth(400);
    GridPane.setConstraints(tbTo, 1, 0);
    grid.getChildren().add(tbTo);

    final Label subjectLabel = new Label("Subject:");
    GridPane.setConstraints(subjectLabel, 0, 1);
    grid.getChildren().add(subjectLabel);

    final TextField tbSubject = new TextField();
    tbTo.setPrefWidth(400);
    GridPane.setConstraints(tbSubject, 1, 1);
    grid.getChildren().add(tbSubject);

    root.getChildren().add(grid);

    Platform.runLater(() -> {
        final HTMLEditor htmlEditor = new HTMLEditor();
        htmlEditor.setPrefHeight(370);
        root.getChildren().addAll(htmlEditor, new Button("Send"));
    });

    final Label htmlLabel = new Label();
    htmlLabel.setWrapText(true);
    getChildren().add(root);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:43,代码来源:HTMLEditorSample.java

示例15: initialize

import javafx.scene.layout.GridPane; //导入方法依赖的package包/类
public void initialize(URL location, ResourceBundle resources) {
    pane.setTop(new HiddenPowerView().getView());
    pane.setLeft(new ConfigurationView().getView());
    pane.setRight(new ResetView().getView());
    pane.setBottom(new OutputView().getView());

    ObservableList<Node> children = centerGrid.getChildren();

    StatSelectorView hpSelector = new StatSelectorView(StatSelectorView.injectionStrategy("hp"));
    GridPane hpGrid = (GridPane) hpSelector.getView();
    GridPane.setConstraints(hpGrid, 1, 1);

    StatSelectorView atkSelector = new StatSelectorView(StatSelectorView.injectionStrategy("atk"));
    GridPane atkGrid = (GridPane) atkSelector.getView();
    GridPane.setConstraints(atkGrid, 2, 1);

    StatSelectorView defSelector = new StatSelectorView(StatSelectorView.injectionStrategy("def"));
    GridPane defGrid = (GridPane) defSelector.getView();
    GridPane.setConstraints(defGrid, 3, 1);

    StatSelectorView spAtkSelector = new StatSelectorView(StatSelectorView.injectionStrategy("spAtk"));
    GridPane spAtkGrid = (GridPane) spAtkSelector.getView();
    GridPane.setConstraints(spAtkGrid, 4, 1);

    StatSelectorView spDefSelector = new StatSelectorView(StatSelectorView.injectionStrategy("spDef"));
    GridPane spDefGrid = (GridPane) spDefSelector.getView();
    GridPane.setConstraints(spDefGrid, 5, 1);

    StatSelectorView spdSelector = new StatSelectorView(StatSelectorView.injectionStrategy("spd"));
    GridPane spdGrid = (GridPane) spdSelector.getView();
    GridPane.setConstraints(spdGrid, 6, 1);

    children.addAll(hpGrid, atkGrid, defGrid, spAtkGrid, spDefGrid, spdGrid);

    natureLabels.put("atk", atkNatureLabel);
    natureLabels.put("def", defNatureLabel);
    natureLabels.put("spd", spdNatureLabel);
    natureLabels.put("spAtk", spAtkNatureLabel);
    natureLabels.put("spDef", spDefNatureLabel);

    natureCalculator.minusNatureProperty().addListener((o, old, newNature) ->
            formatNatures(newNature, natureCalculator.plusNatureProperty().get()));

    natureCalculator.plusNatureProperty().addListener((o, old, newNature) ->
            formatNatures(natureCalculator.minusNatureProperty().get(), newNature));
}
 
开发者ID:wartab,项目名称:gen7-iv-calculator,代码行数:47,代码来源:CalculatorPresenter.java


注:本文中的javafx.scene.layout.GridPane.setConstraints方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。