问题标签 [hbox]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
692 浏览

java - 将 ObservableList 添加到 HBox?

我有一组 JavaFX 标签要添加到 HBox 中。但是我知道 HBox.add 方法不接受 Collection 类型。因此,我改为通过循环添加它。不幸的是,一次只执行一个标签,并没有全部显示出来。任何想法为什么?

  • 我有四个相同大小的 ObservableLists。OutofboundsException 在这里不是问题。test.length 与所有四个列表的大小相同。

  • 这是一个有很多代码的大项目,因此我不适合在这里分享所有代码。但是,您可以查看我的 github 以获取详细示例 https://github.com/ariff20/UPSR

尽管 test.length 大于 1,但仅添加 Cikgu Suraya 行标签。

输出 :

仅显示 Cikgu Suraya 行标签

Test.length 的大小输出:

在此处输入图像描述

它运行两次,但只显示一行标签。

0 投票
0 回答
724 浏览

arraylist - Arrarylist 到 hbox 到 gridpane

感谢您花时间帮助我。我正在制作一个游戏板,我希望将图像的 ArrayList 添加到 hbox 中,然后添加到您认为更好的 gridpane 或 tilepane 中。我认为是瓷砖。我正在尝试使用循环遍历 arraylist 来制作图像视图。但是你可以看到我没有得到任何结果。请帮助再次感谢您的帮助。我试图开始工作的方法是 addGridPane。初级阶段也有我的主菜单,类型为边框窗格。我的网格窗格在边框窗格内居中。

0 投票
1 回答
1269 浏览

javafx - HBox:适合父 AnchorPane Javafx,不使用 FXML

我们如何像在 FXML 场景构建器中那样设置一个适合其父 AnchorPane 的 hbox。

我希望 menuBar 在调整窗口大小时自动调整大小。

0 投票
0 回答
23 浏览

java - GridPanels 的 Hbox 位置

我正在尝试拥有一个带有两个 GridPanel 的 HBox,一个较大的在左侧,一个较小的在右侧(从场景右侧的末端开始)但是我无法将它们放在我想要的位置。这就是它现在的样子。如您所见,红色的 GridPane 位于另一个之上。红色面板应该一直向右等待。此外,即使将某些按钮或文本添加到任一 GridPanes 中,我也希望它们保持在同一位置。

这是我的代码:

测试按钮面板应该在左边,分数面板是红色的,应该在右边。我希望你能帮助我。非常感谢你。=)

0 投票
1 回答
1135 浏览

java - 如何在 ListView 中使用自定义单元格下载 fxml?

我想在ListView. 原谅我的英语不好!我想在ListView. 为此,我使用了一个不同Fxml的包含Hbox.

0 投票
1 回答
1827 浏览

javafx - 在 javafx 中迭代一个 hbox

我在我的 javafx 应用程序中有一个带有 ImageViews 的HBox,现在我需要一些方法来遍历这个 HBox,但我找不到如何做到这一点的算法,我试图做这样的事情:

其中 stack 是我的HBox,但是以这种方式的 ImageViews 将被复制,这是我不想要的。我不知道为什么所以我该怎么做..

0 投票
1 回答
44 浏览

javafx - ContextMenu 每秒显示一次没有右下边框

我在元素 SubjectListItem 上创建了 contextMenu,它像这样扩展了 HBox:

变量 contextMenu 是 SubjectListItem 的私有 final 字段,它被设置为:

在 ListView 上由 list.setCellFactory(c -> new SubjectCell());

问题是每隔一次(第二次,第四次......)边界(右侧和底部被切割: 裁切 ContextMenu 的边框

但是第一次,第三次……没关系。这是javafx的错误还是我做错了什么?

0 投票
0 回答
642 浏览

css - HBox JavaFX 中儿童的 CSS 样式

我正在尝试为我的纸牌游戏项目制作一个登录屏幕,用户可以在其中选择他想要获得的卡。我通过从扩展 Rectangle 并调用超类的构造函数的类 Card 创建卡片来做到这一点。然后,我将创建的卡片添加到 HBox 中供用户选择并给他们一个 ID。这个想法是,当用户悬停或点击其中一张卡片(HBox 的子卡片)时,卡片会改变不透明度以让用户知道他们做了什么。问题是……它不起作用。

从 LoginScreen 类:

来自 CSS 类:

悬停一:

0 投票
1 回答
1777 浏览

javafx - JavaFX HBox 调整大小策略

假设我的 HBox 有以下孩子:

这个 HBox 可以调整为任何值。我如何确保第一个 TextFlow 始终适合其内容的大小而无需换行?

换句话说 - 我希望第一个 TextFlow 在访问 HBox 空间方面具有最终优先级。

0 投票
1 回答
184 浏览

javafx - Drawing node on top of the others in HBox

I am looking for a way to draw a node on top of the neighbouring ones in a HBox. Default behaviour means it is drawn on top of the previous one, but that also means the next one is drawn on top of it. For other containers, one could use the Node.toFront(), but changing the position of the node in the list containing a HBox's children also changes the actual position in the HBox, which is unwanted behaviour in my case. I appreciate any help, thank you.

EDIT: The overlapping occurs when applying a DropShadow effect on an Ellipse and wrapping them in a StackPane along with a Text. It looks like the effect has a weird interaction with the HBox, as it works as intended without it. After adding the effect, it allocates more horizontal space for the ellipse, but not enough to cover the margins of the effect. Also, when clicking anywhere in the whole right half of the black rectangle, the mouse click is dispatched to the stackPane event handler, not to the rectangle's.

This happens