The example should show that the CheckBox (check) is not aligned with the ComboBox. It should be at the same vertical location and the left distance should be 80px. Instead it has 80px to left _and_ the top.
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
public class Test extends Application {
@Override
public void start(Stage primaryStage) {
ComboBox box = new ComboBox();
CheckBox check = new CheckBox();
check.setPadding(new Insets(0,0,0,80));
HBox root = new HBox(box, check);
root.setAlignment(Pos.BASELINE_LEFT);
Scene scene = new Scene(root, 400, 250);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
public class Test extends Application {
@Override
public void start(Stage primaryStage) {
ComboBox box = new ComboBox();
CheckBox check = new CheckBox();
check.setPadding(new Insets(0,0,0,80));
HBox root = new HBox(box, check);
root.setAlignment(Pos.BASELINE_LEFT);
Scene scene = new Scene(root, 400, 250);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
- duplicates
-
JDK-8175160 CheckBox top padding does nothing, while left padding pads top and left.
-
- Closed
-