简体   繁体   English

Javafx 窗格与区域?

[英]Javafx Pane vs Region?

According to the documentation, both Region and Pane will resize any resizable child nodes to their preferred size, but will not reposition them.根据文档,Region 和 Pane 都会将任何可调整大小的子节点调整为它们的首选大小,但不会重新定位它们。

So i can't see where the differencies between these two containers remain and when use one or another.所以我看不出这两个容器之间的差异在哪里以及何时使用一个或另一个。

Region is a superclass for components that have child nodes. Region是具有子节点的组件的超类。

The difference is that Region doesn't allow to manipulate its children through the public API.不同之处在于Region不允许通过公共 API 操作其子级。 The Region.getChildren() method is protected: Region.getChildren()方法受到保护:

new Region().getChildren().add(...); // doesn't compile
new Pane().getChildren().add(...); // works

Why is that?这是为什么?

Because Region is dedicated to component developers, and it allows them to choose if they want to allow API users to work with children directly (like Pane , HBox , etc.) or not (like charts).因为Region是专供组件开发人员使用的,它允许他们选择是否允许 API 用户直接与孩子一起工作(如PaneHBox等)或不(如图表)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM