1. TitledPane 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 45 46 47 48 49 50 51 52 53 54 55 56 | import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Node; import javafx.scene.Scene; import javafx.scene.control.Accordion; import javafx.scene.control.Label; import javafx.scene.control.TitledPane; import javafx.scene.layout.BorderPane; import javafx.scene.paint.Color; import javafx.stage.Stage; public class FxTitlePane extends Application implements FxNode { TitledPane pane; public static void main(String[] args) { Application.launch(args); } @Override public void start(Stage stage) { Group root = new Group(); Scene scene = new Scene(root, 400, 250, Color.WHITE); BorderPane borderPane = new BorderPane(); borderPane.prefHeightProperty().bind(scene.heightProperty()); borderPane.prefWidthProperty().bind(scene.widthProperty()); borderPane.setCenter(pane); root.getChildren().add(borderPane); stage.setTitle("TitledPane"); stage.setScene(scene); stage.show(); add("TitleB", new Label("TitleBB"), true); } public FxTitlePane() { pane = new TitledPane(); } public FxTitlePane(String title, Node item, boolean scrollable) { this(); add( title, item, scrollable ); } @Override public TitledPane get() { return pane; } public void add(String title, Node item, boolean scrollable) { pane.setText(title); pane.setContent(item); pane.setExpanded(true); pane.setCollapsible(scrollable); } } |
2. TitledPanes (Accordion) 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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Node; import javafx.scene.Scene; import javafx.scene.control.Accordion; import javafx.scene.control.Label; import javafx.scene.control.TitledPane; import javafx.scene.layout.BorderPane; import javafx.scene.paint.Color; import javafx.stage.Stage; public class FxTitlePanes extends Application implements FxNode { Accordion pane; public static void main(String[] args) { Application.launch(args); } @Override public void start(Stage stage) { Group root = new Group(); Scene scene = new Scene(root, 400, 250, Color.WHITE); BorderPane borderPane = new BorderPane(); borderPane.prefHeightProperty().bind(scene.heightProperty()); borderPane.prefWidthProperty().bind(scene.widthProperty()); borderPane.setCenter(pane); root.getChildren().add(borderPane); stage.setTitle("TitledPane"); stage.setScene(scene); stage.show(); add("TitleA", new Label("TitleAA"), true); add("TitleB", new Label("TitleBB"), true); } public FxTitlePanes() { pane = new Accordion(); } @Override public Accordion get() { return pane; } public void add(String title, Node item, boolean scrollable) { TitledPane titledPane = new TitledPane(); titledPane.setText(title); titledPane.setContent(item); titledPane.setExpanded(true); titledPane.setCollapsible(scrollable); pane.getPanes().add(titledPane); } public void add(String title, Node item) { add( title, item, true ); } } |
댓글 없음:
댓글 쓰기