- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
这听起来像是重复的,因为有很多关于调整子 Pane 大小以适应父 Pane 的问题,但我几乎尝试了所有方法,但没有任何运气。
我的 SplitPane 位于 AnchorPane 内部,这是我的原始代码:
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity"
minWidth="-Infinity" prefHeight="792.0" prefWidth="1055.0"
xmlns="http://javafx.com/javafx/null" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="com.judeochalifu.stock_manager.controller.NewSupplierController">
<children>
<SplitPane fx:id="splitPlane" dividerPositions="0.5" layoutX="371.0" layoutY="229.0" prefHeight="792.0" prefWidth="1055.0"orientation="VERTICAL" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<items>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0" />
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0" />
</items>
</SplitPane>
</children>
</AnchorPane>
这是未调整大小的输出:
当我拖动窗口以增加宽度或高度时,这就是我得到的:
期望的结果是SplitPane随着窗口的扩展而扩展,即根据Anchorpane的宽度和高度调整大小。
环顾四周,我发现这两个问题OP正在尝试类似的事情:
JavaFX: FXML: How to make the child to extend its size to fit the parent pane?
JavaFX Panel inside Panel autoresizing
答案建议仅使用属性:
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"
在子 Pane 内。我尝试过,但没有成功:这就是我的代码现在的样子:
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity"
minWidth="-Infinity" prefHeight="792.0" prefWidth="1055.0"
xmlns="http://javafx.com/javafx/null" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="com.judeochalifu.stock_manager.controller.NewSupplierController">
<children>
<SplitPane fx:id="splitPlane" dividerPositions="0.5" "orientation="VERTICAL"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<items>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0"
prefWidth="160.0" />
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0"
prefWidth="160.0" />
</items>
</SplitPane>
</children>
</AnchorPane>
我错过了什么?
最佳答案
我无法编译您的代码,因为其中存在错误。第一个示例中的 prefWidth
和 orientation
参数之间缺少空格,而第二个示例中的 orientation
参数之前有不必要的引号。修复它们后,一切都按预期工作。
这是固定代码:
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity"
minWidth="-Infinity" prefHeight="792.0" prefWidth="1055.0"
xmlns="http://javafx.com/javafx/null" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="com.judeochalifu.stock_manager.controller.NewSupplierController">
<children>
<SplitPane fx:id="splitPlane" dividerPositions="0.5" orientation="VERTICAL"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<items>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0"/>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0"/>
</items>
</SplitPane>
</children>
</AnchorPane>
请注意,您可以指定 SplitPane 的 prefWidth
、prefHeight
、layoutX
和 layoutY
,但由于 anchor 设置为 0,并且它是 AnchorPane
的唯一子级,因此它将始终占用所有可用空间,因此是多余的。
关于java - 调整 SplitPane 的大小以适合 AnchorPane 父级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38945441/
当我有一个透明的 SplitPane 时,设置 pickOnBounds=false 不起作用,我无法单击拆分 Pane 后面的按钮。我有一个带有 pickOnBounds=false 的透明 VBo
我想创建一个像这样的分割面板: 我怎样才能做到这一点。当我添加选项卡时,我只能将它们添加到以下位置:上、下、右、左。 这就是我所拥有的: 我该怎么做? 最佳答案 左侧面板应使用CardLayout
我有一个BorderPane 。在此 Pane 中,我将 HBox 设置为顶部有几个控件。在中心我有e SplitPane有两个 Canvas 。我想让鼠标移动到 BorderPane当它从Split
有没有办法让分割 Pane 中的分隔线透明? 我尝试了以下方法 .split-pane *.split-pane-divider { -fx-padding: 0 1 0 1; } 但它不起作用。 另
我尝试实现 here 中的标准示例,看起来像这样: SplitPane sp = new SplitPane(); final StackPane sp1 = new StackPane(); sp1
我一直在java swing中使用jsplit Pane ,我试图在一个主框架中设置水平和垂直分割 Pane ,首先将主框架划分为左侧面板和右侧面板,然后将右侧面板分为底部和右侧面板顶部面板。我成功地
这是一个交叉帖子:http://mail.openjdk.java.net/pipermail/openjfx-dev/2015-January/016437.html 有时当我设置 SplitPan
如何实现整个 SplitPane 的比例调整? public class JfxSplitPaneTest extends Application { @Override public
我一直在使用 JPanels 等来构建我的 GUI。我现在工作的地方他们使用 SWT 来构建他们的 GUI。我有一个复合 Material ,我添加了一个窗框,根据模板的某些属性将窗框垂直或水平分割。
我已经对这个主题做了一些研究并找到了 a post that could’ve been relevant , 如果它只包含我想要的那种答案。我想移除 SplitPane 周围的边框,您在彼此中创建的
我的 .fxml 文件中有许多 Pane (这是我的 fxml 的早期版本: Javafx : SplitPane resize children )现在我想修复顶部分割 Pane 中的前两个元素我的
我喜欢一个 .fxml 文件,我在其中添加了一些 TitledPane,但我无法在应用程序中调整它们的大小。这是代码:
在底部,我有一个 AnchorPane,然后是一个 SplitPane。在左侧 Pane 中,我有一个 listView,根据所选的列表元素,右侧 Pane 会显示相应的内容。我这样做的方法是重叠 A
我有以下代码: public class JavaFxApplication2 extends Application { @Override public void start(St
我有一个 SplitPane,我需要将布局划分为 25% 和 75%。另外,我需要禁止在 25% 分割后向右侧拖动。但是我可以在 25% 的空间内拖动到任何程度。请帮忙。 最佳答案 SplitPane
我所追求的当前布局只是一个水平分割 Pane ,其中左侧是复选框,右侧将输出。在用户检查所有想要的项目后,我最终将在左侧添加一个提交按钮,并将结果显示在右侧。当前的问题是我什至无法显示背景颜色,并且复
自从从以前的 JavaFX 2.0 版本更新到 JavaFX 2.0 b36(Windows SDK(32 位)+ Netbeans 插件)后,SplitPane 控件不再按预期工作。 分隔线无法移动
我需要在应用程序启动时加载 JavaFX TreeView 数据。问题是节点lookup()方法总是返回null。 代码 public class Main extends Application {
我不知道如何在 JavaFX 8 SplitPane 上监听“Divider Repositioned”事件。这是一个简单的工作应用程序,只需要添加事件监听器。有人可以帮助我指出正确的方向吗? pub
我在我的 JSplitPane 中设置了 setOneTouchExpandable(true) 和 setEnabled(false) 以允许用户仅向左或向右展开。但我真正想要的是让左侧面板向左折叠
我是一名优秀的程序员,十分优秀!