如何在 Java FX 工具栏中右对齐按钮 [英] How to right align a button in Java FX toolbar

查看:31
本文介绍了如何在 Java FX 工具栏中右对齐按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Java FX 场景构建器构建 UI,我希望工具栏中的按钮浮动到工具栏的右侧.我尝试更改父节点(工具栏)和按钮的节点方向,但似乎都被忽略了.

I am building a UI using Java FX scene builder and I want a button in a toolbar to float towards the right side of the toolbar. I have tried changing the node orientation of the parent(toolbar) and also the button but both seem to be ignored.

推荐答案

添加一个没有内容的窗格,该窗格始终会增长以适应栏中左对齐工具和右对齐工具之间的可用空间.

Add a pane with no content which always grows to fit available space between the left aligned tools in the bar and right aligned ones.

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<ToolBar prefHeight="40.0" prefWidth="318.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8">
   <Button text="Apples" />
   <Button text="Oranges" />
   <Pane HBox.hgrow="ALWAYS" />
   <Button text="Help" />
</ToolBar>

这篇关于如何在 Java FX 工具栏中右对齐按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆