Java Code Examples for javafx.scene.layout.GridPane#setPadding()

The following examples show how to use javafx.scene.layout.GridPane#setPadding() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UpdatePane.java    From Recaf with MIT License 8 votes vote down vote up
/**
 * @param controller
 * 		Controller to use to close Recaf.
 */
public UpdatePane(GuiController controller) {
	this.controller = controller;
	Button btn = getButton();
	GridPane grid = new GridPane();
	GridPane.setFillHeight(btn, true);
	GridPane.setFillWidth(btn, true);
	grid.setPadding(new Insets(10));
	grid.setVgap(10);
	grid.setHgap(10);
	grid.add(getNotes(), 0, 0, 2, 1);
	grid.add(getInfo(), 0, 1, 1, 1);
	grid.add(btn, 1, 1, 1, 1);
	grid.add(getSubMessage(), 0, 2, 2, 1);
	setTop(getHeader());
	setCenter(grid);
}
 
Example 2
Source File: DataManipulationUI.java    From SONDY with GNU General Public License v3.0 6 votes vote down vote up
public DataManipulationUI(){
    StyleManager.getInstance().addUserAgentStylesheet(PropertySheet.class.getResource("propertysheet.css").toExternalForm());

    // Initializing the main grid
    grid = new GridPane();
    grid.setPadding(new Insets(5,5,5,5));
    
    // Adding separators
    grid.add(new Text("Available datasets"),0,0);
    grid.add(new Separator(),0,1);
    grid.add(new Text("Import a dataset"),0,3);
    grid.add(new Separator(),0,4);
    grid.add(new Text("Preprocess the selected dataset"),0,6);
    grid.add(new Separator(),0,7);
    grid.add(new Text("Filter the selected preprocessed dataset"),0,9);
    grid.add(new Separator(),0,10);
    
    // Initializing specific UIs
    availableDatasetsUI();
    newDatasetProperties = new HashMap<>();
    importUI();
    preprocessUI();
    filterUI();
}
 
Example 3
Source File: TrayDemo.java    From oim-fx with MIT License 6 votes vote down vote up
@Override
public void start(final Stage stage) throws Exception {
	enableTray(stage);

	GridPane grid = new GridPane();
	grid.setAlignment(Pos.CENTER);
	grid.setHgap(20);
	grid.setVgap(20);
	grid.setGridLinesVisible(true);
	grid.setPadding(new Insets(25, 25, 25, 25));

	Button b1 = new Button("测试1");
	Button b2 = new Button("测试2");
	grid.add(b1, 0, 0);
	grid.add(b2, 1, 1);

	Scene scene = new Scene(grid, 800, 600);
	stage.setScene(scene);
	stage.setOnCloseRequest(new EventHandler<WindowEvent>() {

		@Override
		public void handle(WindowEvent arg0) {
			stage.hide();
		}
	});
}
 
Example 4
Source File: ClockOfClocks.java    From medusademo with Apache License 2.0 6 votes vote down vote up
@Override public void start(Stage stage) {
    Region spacer = new Region();
    spacer.setPrefWidth(30);
    GridPane pane = new GridPane();
    pane.add(hourLeft, 0, 0);
    pane.add(hourRight, 1, 0);
    pane.add(spacer, 2, 0);
    pane.add(minLeft, 3, 0);
    pane.add(minRight,4, 0);
    pane.setHgap(10);
    pane.setPadding(new Insets(20, 20, 25, 20));

    Scene scene = new Scene(pane);

    stage.setTitle("Medusa Clock of Clocks");
    stage.setScene(scene);
    stage.show();

    timer.start();

    // Calculate number of nodes
    calcNoOfNodes(pane);
    System.out.println(noOfNodes + " Nodes in SceneGraph");
}
 
Example 5
Source File: Example1.java    From chuidiang-ejemplos with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void buildAndShowMainWindow(Stage primaryStage) {
    primaryStage.setTitle("Hello World!!");
    GridPane gridPane = new GridPane();
    gridPane.setAlignment(Pos.CENTER);
    gridPane.setHgap(10);
    gridPane.setVgap(10);
    gridPane.setPadding(new Insets(25, 25, 25, 25));

    button = new Button("Click me!");
    gridPane.add(button,1,1);

    text = new TextField();
    gridPane.add(text, 2, 1);

    clockLabel = new Label();
    gridPane.add(clockLabel, 1,2, 2, 1);

    Scene scene = new Scene(gridPane);
    primaryStage.setScene(scene);
    primaryStage.show();
}
 
Example 6
Source File: MutableOfferView.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private void addGridPane() {
    gridPane = new GridPane();
    gridPane.getStyleClass().add("content-pane");
    gridPane.setPadding(new Insets(30, 25, -1, 25));
    gridPane.setHgap(5);
    gridPane.setVgap(5);
    ColumnConstraints columnConstraints1 = new ColumnConstraints();
    columnConstraints1.setHalignment(HPos.RIGHT);
    columnConstraints1.setHgrow(Priority.NEVER);
    columnConstraints1.setMinWidth(200);
    ColumnConstraints columnConstraints2 = new ColumnConstraints();
    columnConstraints2.setHgrow(Priority.ALWAYS);
    gridPane.getColumnConstraints().addAll(columnConstraints1, columnConstraints2);
    scrollPane.setContent(gridPane);
}
 
Example 7
Source File: Properties.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
private void setCommand(final TreeItem<ScanCommand> tree_item)
{
    final GridPane prop_grid = new GridPane();
    prop_grid.setPadding(new Insets(5));
    prop_grid.setHgap(5);
    prop_grid.setVgap(5);

    if (tree_item != null)
    {
        int row = 0;
        for (ScanCommandProperty prop : tree_item.getValue().getProperties())
        {
            final Label label = new Label(prop.getName());
            prop_grid.add(label, 0, row);

            try
            {
                final Node editor = createEditor(tree_item, prop);
                GridPane.setHgrow(editor, Priority.ALWAYS);
                GridPane.setFillWidth(editor, true);

                // Label defaults to vertical center,
                // which is good for one-line editors.
                if (editor instanceof StringArrayEditor)
                    GridPane.setValignment(label, VPos.TOP);

                prop_grid.add(editor, 1, row++);
            }
            catch (Exception ex)
            {
                logger.log(Level.WARNING, "Cannot create editor for " + prop, ex);
            }
            ++row;
        }
    }

    scroll.setContent(prop_grid);
}
 
Example 8
Source File: Exercise_17_11.java    From Intro-to-Java-Programming with MIT License 5 votes vote down vote up
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
	// Create a label
	Label lblText = new Label();
	lblText.setText(
		"If you split a file named temp.txt into 3 smaller files,\n" +
		"the three smaller files are temp.txt.1, temp.txt.2, and temp.txt.3.");

	// Create a grid pane for labels and text fields
	GridPane paneForInfo = new GridPane();
	paneForInfo.setPadding(new Insets(5, 15, 5, 0));
	paneForInfo.setHgap(5);
	paneForInfo.add(new Label("Enter a file:"), 0, 0);
	paneForInfo.add(tfFileName, 1, 0);
	paneForInfo.add(new Label("Specify the number of smaller files:"), 0, 1);
	paneForInfo.add(tfnumberOfFiles, 1, 1);

	// Create start button
	Button btStart = new Button("Start");

	// Create a border pane and place node in it
	BorderPane pane = new BorderPane();
	pane.setTop(lblText);
	pane.setCenter(paneForInfo);
	pane.setBottom(btStart);
	pane.setAlignment(btStart, Pos.CENTER);

	// Create and register the handle
	btStart.setOnAction(e -> start());

	// Create a scene and place it in the stage
	Scene scene = new Scene(pane);
	primaryStage.setTitle("Exercise_17_11"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
Example 9
Source File: FlyoutDemo.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates and returns demo widget
 * @return  the control for demo-ing widget
 */
public GridPane getStuffControl() {
    GridPane gp = new GridPane();
    gp.setPadding(new Insets(5, 5, 5, 5));
    gp.setHgap(5);
    
    ComboBox<String> stuffCombo = new ComboBox<>();
    stuffCombo.setEditable(true);
    stuffCombo.setPromptText("Add stuff...");
    stuffCombo.getItems().addAll(
        "Stuff",
        "contained",
        "within",
        "the",
        "combo"
    );
    
    Label l = new Label("Select or enter example text:");
    l.setFont(Font.font(l.getFont().getFamily(), 10));
    l.setTextFill(Color.WHITE);
    Button add = new Button("Add");
    add.setOnAction(e -> stuffCombo.getItems().add(stuffCombo.getSelectionModel().getSelectedItem()));
    Button del = new Button("Clear");
    del.setOnAction(e -> stuffCombo.getSelectionModel().clearSelection());
    gp.add(l, 0, 0, 2, 1);
    gp.add(stuffCombo, 0, 1, 2, 1);
    gp.add(add, 2, 1);
    gp.add(del, 3, 1);
    
    return gp;
}
 
Example 10
Source File: LoginDialog.java    From HubTurbo with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Configures the central grid pane before it's used.
 */
private static void setupGridPane(GridPane grid) {
    grid.setAlignment(Pos.CENTER);
    grid.setHgap(7);
    grid.setVgap(10);
    grid.setPadding(new Insets(25));
    grid.setPrefSize(390, 100);
    grid.setMaxSize(Region.USE_COMPUTED_SIZE, Region.USE_COMPUTED_SIZE);
    applyColumnConstraints(grid, 20, 16, 33, 2, 29);
}
 
Example 11
Source File: Main.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Borders");
    //primaryStage.initStyle(StageStyle.UTILITY); // .UNDECORATED);//
    
    Group root = new Group();
    
    Scene scene = new Scene(root, 600, 330, Color.WHITE); //TRANSPARENT);//
    
    scene.setFill(Color.TRANSPARENT);
    scene.getStylesheets().add(this.getClass().getResource("/fxui/css/demo/main.css").toExternalForm());

    
    GridPane gridpane = new GridPane();
    gridpane.setPadding(new Insets(5));
    gridpane.setHgap(10);
    gridpane.setVgap(10);
    
    final String cssDefault = "-fx-border-color: blue;\n"
            + "-fx-border-insets: 5;\n"
            + "-fx-border-width: 3;\n"
            + "-fx-border-style: dashed;\n";
    final HBox pictureRegion = new HBox();
   
    pictureRegion.setStyle(cssDefault);
    gridpane.add(pictureRegion, 1, 1,10,10);
    
    root.getChildren().add(gridpane);        
    primaryStage.setScene(scene);
    primaryStage.show();
}
 
Example 12
Source File: UserDetails.java    From SmartCity-ParkingManagement with Apache License 2.0 5 votes vote down vote up
public static void display(final Stage primaryStage) {
	window = primaryStage;
	window.setTitle("Get Password By Email");
	final GridPane grid = new GridPane();
	grid.setPadding(new Insets(20, 20, 20, 2));
	grid.setVgap(8);
	grid.setHgap(10);

}
 
Example 13
Source File: BlendEffect.java    From Learn-Java-12-Programming with MIT License 5 votes vote down vote up
public void start1(Stage primaryStage) {
    try {
        BlendMode bm1 = BlendMode.MULTIPLY;
        BlendMode bm2 = BlendMode.SRC_OVER;
        Node[] node = setEffectOnGroup(bm1, bm2);
        //Node[] node = setModeOnGroup(bm1, bm2);
        //Node[] node = setEffectOnCircle(bm1, bm2);
        //Node[] node = setEffectOnSquare(bm1, bm2);
        //Node[] node = setModeOnCircle(bm1, bm2);
        //Node[] node = setModeOnSquare(bm1, bm2);

        GridPane grid = new GridPane();
        grid.setAlignment(Pos.CENTER);
        grid.setHgap(40);
        grid.setVgap(15);
        grid.setPadding(new Insets(20, 20, 20, 20));

        int i = 0;
        grid.addRow(i++, new Text("Circle top"), new Text("Square top"));
        grid.add(node[0],    0, i++, 2, 1);
        GridPane.setHalignment(node[0], HPos.CENTER);
        grid.addRow(i++, node[1], node[2]);
        grid.add(node[3],    0, i++, 2, 1);
        GridPane.setHalignment(node[3], HPos.CENTER);
        grid.addRow(i++, node[4], node[5]);
        Text txt = new Text("Circle opacity - 0.5\nSquare opacity - 1.0");
        grid.add(txt,    0, i++, 2, 1);
        GridPane.setHalignment(txt, HPos.CENTER);

        Scene scene = new Scene(grid, 350, 350);

        primaryStage.setScene(scene);
        primaryStage.setTitle("JavaFX blend effect");
        primaryStage.onCloseRequestProperty()
                .setValue(e -> System.out.println("Bye! See you later!"));
        primaryStage.show();
    } catch (Exception ex){
        ex.printStackTrace();
    }
}
 
Example 14
Source File: Overlay.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
protected void createGridPane() {
    gridPane = new GridPane();
    gridPane.setHgap(5);
    gridPane.setVgap(5);
    gridPane.setPadding(new Insets(64, 64, 64, 64));
    gridPane.setPrefWidth(width);

    ColumnConstraints columnConstraints1 = new ColumnConstraints();
    columnConstraints1.setHalignment(HPos.RIGHT);
    columnConstraints1.setHgrow(Priority.SOMETIMES);
    ColumnConstraints columnConstraints2 = new ColumnConstraints();
    columnConstraints2.setHgrow(Priority.ALWAYS);
    gridPane.getColumnConstraints().addAll(columnConstraints1, columnConstraints2);
}
 
Example 15
Source File: ProposalResultsWindow.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private GridPane createVotesTable() {
    GridPane votesGridPane = new GridPane();
    votesGridPane.setHgap(5);
    votesGridPane.setVgap(5);
    votesGridPane.setPadding(new Insets(15));

    ColumnConstraints columnConstraints1 = new ColumnConstraints();
    columnConstraints1.setHalignment(HPos.RIGHT);
    columnConstraints1.setHgrow(Priority.ALWAYS);
    votesGridPane.getColumnConstraints().addAll(columnConstraints1);

    int gridRow = 0;

    TableGroupHeadline votesTableHeader = new TableGroupHeadline(Res.get("dao.results.proposals.voting.detail.header"));
    GridPane.setRowIndex(votesTableHeader, gridRow);
    GridPane.setMargin(votesTableHeader, new Insets(8, 0, 0, 0));
    GridPane.setColumnSpan(votesTableHeader, 2);
    votesGridPane.getChildren().add(votesTableHeader);

    TableView<VoteListItem> votesTableView = new TableView<>();
    votesTableView.setPlaceholder(new AutoTooltipLabel(Res.get("table.placeholder.noData")));
    votesTableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

    createColumns(votesTableView);
    GridPane.setRowIndex(votesTableView, gridRow);
    GridPane.setMargin(votesTableView, new Insets(Layout.FIRST_ROW_DISTANCE, 0, 0, 0));
    GridPane.setColumnSpan(votesTableView, 2);
    GridPane.setVgrow(votesTableView, Priority.ALWAYS);
    votesGridPane.getChildren().add(votesTableView);

    votesTableView.setItems(sortedVotes);

    addCloseButton(votesGridPane, ++gridRow);

    return votesGridPane;
}
 
Example 16
Source File: ProofOfBurnVerificationWindow.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("Duplicates")
@Override
protected void createGridPane() {
    gridPane = new GridPane();
    gridPane.setHgap(5);
    gridPane.setVgap(5);
    gridPane.setPadding(new Insets(64, 64, 64, 64));
    gridPane.setPrefWidth(width);

    ColumnConstraints columnConstraints = new ColumnConstraints();
    columnConstraints.setPercentWidth(100);
    gridPane.getColumnConstraints().add(columnConstraints);
}
 
Example 17
Source File: GitFxDialog.java    From GitFx with Apache License 2.0 4 votes vote down vote up
@Override
    public String gitOpenDialog(String title, String header, String content) {
        String repo;
        DirectoryChooser chooser = new DirectoryChooser();
        Dialog<Pair<String, GitFxDialogResponse>> dialog = new Dialog<>();
        //Dialog<Pair<String, GitFxDialogResponse>> dialog = getCostumeDialog();
        dialog.setTitle(title);
        dialog.setHeaderText(header);
        dialog.setContentText(content);

        ButtonType okButton = new ButtonType("Ok");
        ButtonType cancelButton = new ButtonType("Cancel");
        dialog.getDialogPane().getButtonTypes().addAll(okButton, cancelButton);
        GridPane grid = new GridPane();
        grid.setHgap(10);
        grid.setVgap(10);
        grid.setPadding(new Insets(20, 150, 10, 10));

        TextField repository = new TextField();
        repository.setPrefWidth(250.0);
        repository.setPromptText("Repo");
        grid.add(new Label("Repository:"), 0, 0);
        grid.add(repository, 1, 0);
        
        /////////////////////Modification of choose Button////////////////////////
        Button chooseButtonType = new Button("Choose");
        grid.add(chooseButtonType, 2, 0);
//			        Button btnCancel1 = new Button("Cancel");
//			        btnCancel1.setPrefWidth(90.0);
//			        Button btnOk1 = new Button("Ok");
//			        btnOk1.setPrefWidth(90.0);
//			        HBox hbox = new HBox(4);
//			        hbox.getChildren().addAll(btnOk1,btnCancel1);
//			        hbox.setPadding(new Insets(2));
//			        grid.add(hbox, 1, 1);
        chooseButtonType.setOnAction(new EventHandler<ActionEvent>() {
            @Override public void handle(ActionEvent e) {
               // label.setText("Accepted");
            	File path = chooser.showDialog(dialog.getOwner());
                getFileAndSeText(repository,path);
                chooser.setTitle(resourceBundle.getString("repo"));
            }
        });
//        btnCancel1.setOnAction(new EventHandler<ActionEvent>(){ 
//        	@Override public void handle(ActionEvent e) {
//        	System.out.println("Shyam : Testing");
//        	setResponse(GitFxDialogResponse.CANCEL);
//             }
//		});
        //////////////////////////////////////////////////////////////////////
        dialog.getDialogPane().setContent(grid);

        dialog.setResultConverter(dialogButton -> {
            if (dialogButton == okButton) {
                String filePath = repository.getText();
                //filePath = filePath.concat("/.git");
//[LOG]                logger.debug(filePath);
                if (!filePath.isEmpty() && new File(filePath).exists()) {
                    setResponse(GitFxDialogResponse.OK);
                    return new Pair<>(repository.getText(), GitFxDialogResponse.OK);
                } else {
                    this.gitErrorDialog(resourceBundle.getString("errorOpen"),
                            resourceBundle.getString("errorOpenTitle"),
                            resourceBundle.getString("errorOpenDesc"));
                }

            }
            if (dialogButton == cancelButton) {
//[LOG]                logger.debug("Cancel clicked");
                setResponse(GitFxDialogResponse.CANCEL);
                return new Pair<>(null, GitFxDialogResponse.CANCEL);
            }
            return null;
        });

        Optional<Pair<String, GitFxDialogResponse>> result = dialog.showAndWait();

        result.ifPresent(repoPath -> {
//[LOG]            logger.debug(repoPath.getKey() + " " + repoPath.getValue().toString());
        });

        Pair<String, GitFxDialogResponse> temp = null;
        if (result.isPresent()) {
            temp = result.get();
        }

        if(temp != null){
            return temp.getKey();// + "/.git";
        }
        return EMPTY_STRING;

    }
 
Example 18
Source File: RefImplToolBar.java    From FXMaps with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Creates and returns the control for loading maps
 * @return  the control for loading stored maps
 */
public GridPane getMapControl() {
    GridPane gp = new GridPane();
    gp.setPadding(new Insets(5, 5, 5, 5));
    gp.setHgap(5);
    gp.setVgap(5);
    
    Button gpxLoader = getGPXLoadControl();
    gpxLoader.setPrefHeight(15);
    
    Label l = new Label("Select or enter map name:");
    l.setFont(Font.font(l.getFont().getFamily(), 12));
    l.setTextFill(Color.WHITE);
    
    Button add = new Button("Add");
    add.disableProperty().set(true);
    add.setOnAction(e -> mapCombo.valueProperty().set(mapCombo.getEditor().getText()));
    
    Button clr = new Button("Erase map");
    clr.disableProperty().set(true);
    clr.setOnAction(e -> map.eraseMap());
    
    Button del = new Button("Delete map");
    del.disableProperty().set(true);
    del.setOnAction(e -> {
        map.clearMap();
        map.deleteMap(mapCombo.getEditor().getText());
        mapCombo.getItems().remove(mapCombo.getEditor().getText());
        mapCombo.getSelectionModel().clearSelection();
        mapCombo.getEditor().clear();
        map.setMode(Mode.NORMAL);
        mapChooser.fire();
        map.setOverlayVisible(true);
        routeChooser.setDisable(true);
    });
    
    mapCombo.getEditor().textProperty().addListener((v, o, n) -> {
        if(mapCombo.getEditor().getText() != null && mapCombo.getEditor().getText().length() > 0) {
            add.disableProperty().set(false);
            if(map.getMapStore().getMap(mapCombo.getEditor().getText()) != null) {
                clr.disableProperty().set(false);
                del.disableProperty().set(false);
            }else{
                clr.disableProperty().set(true);
                del.disableProperty().set(true);
            }
        }else{
            add.disableProperty().set(true);
            clr.disableProperty().set(true);
            del.disableProperty().set(true);
        }
    });
    
    gp.add(gpxLoader, 0, 0, 2, 1);
    gp.add(new Separator(), 0, 1, 2, 1);
    gp.add(l, 0, 2, 2, 1);
    gp.add(mapCombo, 0, 3, 3, 1);
    gp.add(add, 3, 3);
    gp.add(clr, 4, 3);
    gp.add(del, 5, 3);
    
    return gp;
}
 
Example 19
Source File: AgentRegistrationView.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
private void buildUI() {
    GridPane gridPane = new GridPane();
    gridPane.setPadding(new Insets(30, 25, -1, 25));
    gridPane.setHgap(5);
    gridPane.setVgap(5);
    ColumnConstraints columnConstraints1 = new ColumnConstraints();
    columnConstraints1.setHgrow(Priority.SOMETIMES);
    columnConstraints1.setMinWidth(200);
    columnConstraints1.setMaxWidth(500);
    gridPane.getColumnConstraints().addAll(columnConstraints1);
    root.getChildren().add(gridPane);

    addTitledGroupBg(gridPane, gridRow, 4, Res.get("account.arbitratorRegistration.registration", getRole()));
    TextField pubKeyTextField = addTopLabelTextField(gridPane, gridRow, Res.get("account.arbitratorRegistration.pubKey"),
            model.registrationPubKeyAsHex.get(), Layout.FIRST_ROW_DISTANCE).second;

    pubKeyTextField.textProperty().bind(model.registrationPubKeyAsHex);

    Tuple3<Label, ListView<String>, VBox> tuple = FormBuilder.addTopLabelListView(gridPane, ++gridRow, Res.get("shared.yourLanguage"));
    GridPane.setValignment(tuple.first, VPos.TOP);
    languagesListView = tuple.second;
    languagesListView.disableProperty().bind(model.registrationEditDisabled);
    languagesListView.setMinHeight(3 * Layout.LIST_ROW_HEIGHT + 2);
    languagesListView.setMaxHeight(6 * Layout.LIST_ROW_HEIGHT + 2);
    languagesListView.setCellFactory(new Callback<>() {
        @Override
        public ListCell<String> call(ListView<String> list) {
            return new ListCell<>() {
                final Label label = new AutoTooltipLabel();
                final ImageView icon = ImageUtil.getImageViewById(ImageUtil.REMOVE_ICON);
                final Button removeButton = new AutoTooltipButton("", icon);
                final AnchorPane pane = new AnchorPane(label, removeButton);

                {
                    label.setLayoutY(5);
                    removeButton.setId("icon-button");
                    AnchorPane.setRightAnchor(removeButton, 0d);
                }

                @Override
                public void updateItem(final String item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        label.setText(LanguageUtil.getDisplayName(item));
                        removeButton.setOnAction(e -> onRemoveLanguage(item));
                        setGraphic(pane);
                    } else {
                        setGraphic(null);
                    }
                }
            };
        }
    });

    languageComboBox = FormBuilder.addComboBox(gridPane, ++gridRow);
    languageComboBox.disableProperty().bind(model.registrationEditDisabled);
    languageComboBox.setPromptText(Res.get("shared.addLanguage"));
    languageComboBox.setConverter(new StringConverter<>() {
        @Override
        public String toString(String code) {
            return LanguageUtil.getDisplayName(code);
        }

        @Override
        public String fromString(String s) {
            return null;
        }
    });
    languageComboBox.setOnAction(e -> onAddLanguage());

    Tuple2<Button, Button> buttonButtonTuple2 = add2ButtonsAfterGroup(gridPane, ++gridRow,
            Res.get("account.arbitratorRegistration.register"), Res.get("account.arbitratorRegistration.revoke"));
    Button registerButton = buttonButtonTuple2.first;
    registerButton.disableProperty().bind(model.registrationEditDisabled);
    registerButton.setOnAction(e -> onRegister());

    Button revokeButton = buttonButtonTuple2.second;
    revokeButton.setDefaultButton(false);
    revokeButton.disableProperty().bind(model.revokeButtonDisabled);
    revokeButton.setOnAction(e -> onRevoke());

    final TitledGroupBg titledGroupBg = addTitledGroupBg(gridPane, ++gridRow, 2,
            Res.get("shared.information"), Layout.GROUP_DISTANCE);

    titledGroupBg.getStyleClass().add("last");

    Label infoLabel = addMultilineLabel(gridPane, gridRow);
    GridPane.setMargin(infoLabel, new Insets(Layout.TWICE_FIRST_ROW_AND_GROUP_DISTANCE, 0, 0, 0));
    infoLabel.setText(Res.get("account.arbitratorRegistration.info.msg", getRole().toLowerCase()));
}
 
Example 20
Source File: GitFxDialog.java    From GitFx with Apache License 2.0 4 votes vote down vote up
@Override
    public Pair<String, String> gitCloneDialog(String title, String header,
                                               String content) {
        Dialog<Pair<String, String>> dialog = new Dialog<>();
        DirectoryChooser chooser = new DirectoryChooser();
        dialog.setTitle(title);
        dialog.setHeaderText(header);
        GridPane grid = new GridPane();
        grid.setHgap(10);
        grid.setVgap(10);
        grid.setPadding(new Insets(20, 150, 10, 10));
        TextField remoteRepo = new TextField();
        remoteRepo.setPromptText("Remote Repo URL");
        remoteRepo.setPrefWidth(250.0);
        TextField localPath = new TextField();
        localPath.setPromptText("Local Path");
        localPath.setPrefWidth(250.0);
        grid.add(new Label("Remote Repo URL:"), 0, 0);
        grid.add(remoteRepo, 1, 0);
        grid.add(new Label("Local Path:"), 0, 1);
        grid.add(localPath, 1, 1);
        //ButtonType chooseButtonType = new ButtonType("Choose");
        ButtonType cloneButtonType = new ButtonType("Clone");
        ButtonType cancelButtonType = new ButtonType("Cancel");
        /////////////////////Modification of choose Button////////////////////////
        Button chooseButtonType = new Button("Choose");
        grid.add(chooseButtonType, 2, 1);
        chooseButtonType.setOnAction(new EventHandler<ActionEvent>() {
            @Override public void handle(ActionEvent e) {
            	chooser.setTitle(resourceBundle.getString("cloneRepo"));
                File cloneRepo = chooser.showDialog(dialog.getOwner());
                getFileAndSeText(localPath, cloneRepo);
            }
        });
        //////////////////////////////////////////////////////////////////////
        dialog.getDialogPane().setContent(grid);
        dialog.getDialogPane().getButtonTypes().addAll(
                cloneButtonType, cancelButtonType);

        dialog.setResultConverter(dialogButton -> {
            if (dialogButton == cloneButtonType) {
                setResponse(GitFxDialogResponse.CLONE);
                String remoteRepoURL = remoteRepo.getText();
                String localRepoPath = localPath.getText();
                if (!remoteRepoURL.isEmpty() && !localRepoPath.isEmpty()) {
                    return new Pair<>(remoteRepo.getText(), localPath.getText());
                } else {
                    this.gitErrorDialog(resourceBundle.getString("errorClone"),
                            resourceBundle.getString("errorCloneTitle"),
                            resourceBundle.getString("errorCloneDesc"));
                }
            }
            if (dialogButton == cancelButtonType) {
//[LOG]                logger.debug("Cancel clicked");
                setResponse(GitFxDialogResponse.CANCEL);
                return new Pair<>(null, null);
            }
            return null;
        });
        Optional<Pair<String, String>> result = dialog.showAndWait();
        Pair<String, String> temp = null;
        if (result.isPresent()) {
            temp = result.get();
        }
        return temp;
    }