1つの問題について助けを求めたがっています。私は1つの列に2つのラジオボタンを移動して、それらの上にあるテキストボックスと同じだけ多くのスペースを取るようにします。これどうやってするの?現在の不適切なバージョンのコードとスクリーンショットは次のとおりです:JavaFXを重複させずに2つのラジオボタンを1つの列に配置
あなたが100%確信していない場合は、私の質問に重複しないようにしてください。あなたの質問旗を他の質問の重複として持つことはうれしくなく、この他のものに行き、共通のことは両方ともプログラミングに関することであることが分かります。
GridPane formGrid = new GridPane();
formGrid.setPadding(new Insets(5,5,5,5));
formGrid.setVgap(6);
formGrid.setHgap(4);
//first row
Label nameLabel = new Label("Name");
GridPane.setConstraints(nameLabel, 0, 0);
TextField nameInput = new TextField();
GridPane.setConstraints(nameInput, 1, 0);
Label ageLabel = new Label("Age");
GridPane.setConstraints(ageLabel, 2, 0);
TextField ageInput = new TextField();
GridPane.setConstraints(ageInput, 3, 0);
//secondRow
Label colourLabel = new Label("Colour");
GridPane.setConstraints(colourLabel, 0, 1);
TextField colourInput = new TextField();
GridPane.setConstraints(colourInput, 1, 1);
Label genderLabel = new Label("Gender");
GridPane.setConstraints(genderLabel, 2, 1);
ToggleGroup pickGender = new ToggleGroup();
RadioButton pickMale = new RadioButton("Male");
pickMale.setToggleGroup(pickGender);
pickMale.setSelected(true);
GridPane.setConstraints(pickMale, 3, 1, 1, 1);
RadioButton pickFemale = new RadioButton("Female");
pickFemale.setToggleGroup(pickGender);
GridPane.setConstraints(pickFemale, 4, 1, 1, 1);
//third row
Label typeLabel = new Label("Type");
GridPane.setConstraints(typeLabel, 0, 2);
//combobox
ComboBox<String> typeBox = new ComboBox<>();
GridPane.setConstraints(typeBox, 1, 2);
Label breedLabel = new Label("Breed");
GridPane.setConstraints(breedLabel, 2, 2);
TextField breedInput = new TextField();
GridPane.setConstraints(breedInput, 3, 2);
//fourth row
Label categoryLabel = new Label("Category: ");
GridPane.setConstraints(categoryLabel, 0, 3);
ToggleGroup pickCategory = new ToggleGroup();
RadioButton pickLost = new RadioButton("Lost");
pickLost.setToggleGroup(pickCategory);
pickLost.setSelected(true);
GridPane.setConstraints(pickLost, 1, 3);
RadioButton pickFound = new RadioButton("Found");
pickLost.setToggleGroup(pickCategory);
GridPane.setConstraints(pickFound, 2, 3);
RadioButton pickAdoption = new RadioButton("Adoption");
pickLost.setToggleGroup(pickCategory);
GridPane.setConstraints(pickAdoption, 3, 3);
//fifth row
Label descriptionLabel = new Label("Description");
GridPane.setConstraints(descriptionLabel, 0, 4);
TextArea descriptionInput = new TextArea();
GridPane.setConstraints(descriptionInput, 1, 4, 2, 1);
formGrid.getChildren().addAll(nameLabel, nameInput, ageLabel, ageInput);
formGrid.getChildren().addAll(colourLabel, colourInput, genderLabel, pickMale, pickFemale);
formGrid.getChildren().addAll(typeLabel, typeBox, breedLabel, breedInput, categoryLabel);
formGrid.getChildren().addAll(pickLost, pickFound, pickAdoption, descriptionLabel, descriptionInput);