javafx.scene.Parent.getChildrenUnmodifiable()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(332)

本文整理了Java中javafx.scene.Parent.getChildrenUnmodifiable()方法的一些代码示例,展示了Parent.getChildrenUnmodifiable()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parent.getChildrenUnmodifiable()方法的具体详情如下:
包路径:javafx.scene.Parent
类名称:Parent
方法名:getChildrenUnmodifiable

Parent.getChildrenUnmodifiable介绍

暂无

代码示例

代码示例来源:origin: pmd/pmd

  1. for (Node child : nodes.getChildrenUnmodifiable()) {

代码示例来源:origin: jfoenixadmin/JFoenix

  1. parent.getChildrenUnmodifiable().addListener(new ListChangeListener<Node>() {
  2. @Override
  3. public void onChanged(javafx.collections.ListChangeListener.Change<? extends Node> c) {
  4. for (Node component : parent.getChildrenUnmodifiable()) {
  5. if (component instanceof Pane) {
  6. ((Pane) component).getChildren().addListener(new ListChangeListener<Node>() {

代码示例来源:origin: stackoverflow.com

  1. private void handleFocusChangesStartingFromParentNode(Parent parentNode) {
  2. for (Node node : parentNode.getChildrenUnmodifiable()) {
  3. node.focusedProperty().addListener(new ChangeListener<Boolean>() {
  4. @Override
  5. public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
  6. performHandling();
  7. }
  8. });
  9. try{
  10. handleFocusChangesStartingFromNode((Parent)node);
  11. }catch(ClassCastException e){
  12. }
  13. }
  14. }

代码示例来源:origin: com.guigarage/responsivefx

  1. public static List<Node> getAllNodesInParent(Parent parent) {
  2. List<Node> ret = new ArrayList<>();
  3. for (Node child : parent.getChildrenUnmodifiable()) {
  4. ret.add(child);
  5. if (child instanceof Parent) {
  6. ret.addAll(getAllNodesInParent((Parent) child));
  7. }
  8. }
  9. return ret;
  10. }

代码示例来源:origin: com.guigarage/ui-basics

  1. public static List<Node> getAllNodesInParent(Parent parent) {
  2. List<Node> ret = new ArrayList<>();
  3. for (Node child : parent.getChildrenUnmodifiable()) {
  4. ret.add(child);
  5. if (child instanceof Parent) {
  6. ret.addAll(getAllNodesInParent((Parent) child));
  7. }
  8. }
  9. return ret;
  10. }

代码示例来源:origin: org.loadui/testFx

  1. private static void printGraph( Node root, String indent )
  2. {
  3. System.out.println( indent + root );
  4. if( root instanceof Parent )
  5. {
  6. indent += " ";
  7. for( Node child : ( ( Parent )root ).getChildrenUnmodifiable() )
  8. {
  9. printGraph( child, indent );
  10. }
  11. }
  12. }

代码示例来源:origin: stackoverflow.com

  1. Parent root = FXMLLoader.load(getClass().getResource("fileName.fxml"));
  2. ObservableList<Node> nodes = root.getChildrenUnmodifiable();
  3. String _id = "testButton";
  4. for (Node node : nodes) {
  5. if (node.getId().equals(_id)) {
  6. return node;
  7. }
  8. }
  9. return null;
  10. }

代码示例来源:origin: com.bitplan.gui/com.bitplan.javafx

  1. private static void calcNoOfNodes(Node node) {
  2. if (node instanceof Parent) {
  3. if (((Parent) node).getChildrenUnmodifiable().size() != 0) {
  4. ObservableList<Node> tempChildren = ((Parent) node).getChildrenUnmodifiable();
  5. noOfNodes += tempChildren.size();
  6. for (Node n : tempChildren) { calcNoOfNodes(n); }
  7. }
  8. }
  9. }

代码示例来源:origin: stackoverflow.com

  1. public static ArrayList<Node> getAllNodes(Parent root) {
  2. ArrayList<Node> nodes = new ArrayList<Node>();
  3. addAllDescendents(root, nodes);
  4. return nodes;
  5. }
  6. private static void addAllDescendents(Parent parent, ArrayList<Node> nodes) {
  7. for (Node node : parent.getChildrenUnmodifiable()) {
  8. nodes.add(node);
  9. if (node instanceof Parent)
  10. addAllDescendents((Parent)node, nodes);
  11. }
  12. }

代码示例来源:origin: com.cedarsoft.commons/javafx

  1. private static void dump(Node node, PrintStream out, int depth) {
  2. out.println(Strings.repeat(" ", depth) + node + " #" + node.getId());
  3. Parent parent = (Parent) node;
  4. parent.getChildrenUnmodifiable()
  5. .forEach(child -> {
  6. dump(child, out, depth + 1);
  7. });
  8. }
  9. }

代码示例来源:origin: com.bitplan.gui/com.bitplan.javafx

  1. private static void calcNoOfNodes(Node node) {
  2. if (node instanceof Parent) {
  3. if (((Parent) node).getChildrenUnmodifiable().size() != 0) {
  4. ObservableList<Node> tempChildren = ((Parent) node).getChildrenUnmodifiable();
  5. noOfNodes += tempChildren.size();
  6. tempChildren.forEach(n -> calcNoOfNodes(n));
  7. }
  8. }
  9. }

代码示例来源:origin: stackoverflow.com

  1. if (node instanceof Parent) {
  2. Parent parent = (Parent) node;
  3. ObservableList<Node> children = parent.getChildrenUnmodifiable();
  4. for (Node child : children) {
  5. addListenerDeeply(child, listener);

代码示例来源:origin: com.airhacks/afterburner.fx

  1. /**
  2. * Scene Builder creates for each FXML document a root container. This
  3. * method omits the root container (e.g. AnchorPane) and gives you the
  4. * access to its first child.
  5. *
  6. * @return the first child of the AnchorPane
  7. */
  8. public Node getViewWithoutRootContainer() {
  9. final ObservableList<Node> children = getView().getChildrenUnmodifiable();
  10. if (children.isEmpty()) {
  11. return null;
  12. }
  13. return children.listIterator().next();
  14. }

代码示例来源:origin: de.roskenet/springboot-javafx-support

  1. /**
  2. * Scene Builder creates for each FXML document a root container. This
  3. * method omits the root container (e.g. {@link AnchorPane}) and gives you
  4. * the access to its first child.
  5. *
  6. * @return the first child of the {@link AnchorPane} or null if there are no
  7. * children available from this view.
  8. */
  9. public Node getViewWithoutRootContainer() {
  10. final ObservableList<Node> children = getView().getChildrenUnmodifiable();
  11. if (children.isEmpty()) {
  12. return null;
  13. }
  14. return children.listIterator().next();
  15. }

代码示例来源:origin: com.guigarage/ui-basics

  1. public static void registerRecursiveChildObserver(Window window, Consumer<Node> onRemove, Consumer<Node> onAdd) {
  2. List<Node> allNodes = getAllNodesInWindow(window);
  3. ListChangeListener<Node> listener = createRecursiveChildObserver(onRemove, onAdd);
  4. for (Node child : allNodes) {
  5. if (child instanceof Parent) {
  6. Parent parent = (Parent) child;
  7. parent.getChildrenUnmodifiable().addListener(listener);
  8. }
  9. }
  10. }

代码示例来源:origin: eu.mihosoft.vrl.jcsg/jcsg

  1. public void validate(Node node) {
  2. if (node instanceof MeshView) {
  3. MeshView meshView = (MeshView) node;
  4. validate(meshView.getMesh());
  5. } else if (node instanceof Parent) {
  6. for (Node child : ((Parent) node).getChildrenUnmodifiable()) {
  7. validate(child);
  8. }
  9. }
  10. }

代码示例来源:origin: com.guigarage/responsivefx

  1. public static void registerRecursiveChildObserver(Window window, Consumer<Node> onRemove, Consumer<Node> onAdd) {
  2. List<Node> allNodes = getAllNodesInWindow(window);
  3. ListChangeListener<Node> listener = createRecursiveChildObserver(onRemove, onAdd);
  4. for (Node child : allNodes) {
  5. if (child instanceof Parent) {
  6. Parent parent = (Parent) child;
  7. parent.getChildrenUnmodifiable().addListener(listener);
  8. }
  9. }
  10. }

代码示例来源:origin: eu.mihosoft.vrl.jcsg/jcsg

  1. private void removeEmptyGroups() {
  2. for (Parent p : emptyParents) {
  3. Parent parent = p.getParent();
  4. Group g = (Group) parent;
  5. g.getChildren().addAll(p.getChildrenUnmodifiable());
  6. g.getChildren().remove(p);
  7. }
  8. }

代码示例来源:origin: com.nexitia.emaginplatform/emagin-jfxcore-engine

  1. public static void addListenerDeeply(Node node, EventHandler<MouseEvent> listener) {
  2. node.addEventHandler(MouseEvent.MOUSE_MOVED, listener);
  3. node.addEventHandler(MouseEvent.MOUSE_PRESSED, listener);
  4. node.addEventHandler(MouseEvent.MOUSE_DRAGGED, listener);
  5. node.addEventHandler(MouseEvent.MOUSE_EXITED, listener);
  6. node.addEventHandler(MouseEvent.MOUSE_EXITED_TARGET, listener);
  7. if (node instanceof Parent) {
  8. Parent parent = (Parent) node;
  9. ObservableList<Node> children = parent.getChildrenUnmodifiable();
  10. for (Node child : children) {
  11. addListenerDeeply(child, listener);
  12. }
  13. }
  14. }

代码示例来源:origin: com.nexitia.emaginplatform/emagin-jfxcore-engine

  1. public static void addResizeListener(Stage stage) {
  2. ResizeListener resizeListener = new ResizeListener(stage, null);
  3. stage.getScene().addEventHandler(MouseEvent.MOUSE_MOVED, resizeListener);
  4. stage.getScene().addEventHandler(MouseEvent.MOUSE_PRESSED, resizeListener);
  5. stage.getScene().addEventHandler(MouseEvent.MOUSE_DRAGGED, resizeListener);
  6. stage.getScene().addEventHandler(MouseEvent.MOUSE_EXITED, resizeListener);
  7. stage.getScene().addEventHandler(MouseEvent.MOUSE_EXITED_TARGET, resizeListener);
  8. ObservableList<Node> children = stage.getScene().getRoot().getChildrenUnmodifiable();
  9. for (Node child : children) {
  10. // addListenerDeeply(child, resizeListener);
  11. }
  12. }

相关文章