1. HBox Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | import javafx.geometry.Insets; import javafx.geometry.Orientation; import javafx.geometry.Pos; import javafx.scene.Node; import javafx.scene.control.Separator; import javafx.scene.layout.HBox; public class FxHBox implements FxNode { HBox box; public FxHBox() { box = new HBox(0); box.setAlignment(Pos.CENTER); box.setPadding(new Insets(0, 0, 0, 0)); //T,R,B,L } public FxHBox(int gap) { box = new HBox(gap); box.setAlignment(Pos.CENTER); box.setSpacing(gap); box.setPadding(new Insets(0, 0, 0, 0)); //T,R,B,L } @Override public HBox get() { return box; } public void add(FxNode item) { box.getChildren().add(item.get()); } public void add(Node item) { box.getChildren().add(item); } public void addSeparator() { Separator sep = new Separator(); sep.setOrientation(Orientation.VERTICAL); box.getChildren().add(sep); } } |
2. VBox Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.Node; import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; public class FxVBox implements FxNode { final int gap = 0; VBox box; public FxVBox() { box = new VBox(gap); box.setAlignment(Pos.CENTER); box.setSpacing(gap); box.setPadding(new Insets(0, 0, 0, 0)); //T,R,B,L } @Override public VBox get() { return box; } public void add(Node item) { box.getChildren().add(item); } public void add(FxNode item) { box.getChildren().add(item.get()); } } |
댓글 없음:
댓글 쓰기