窗口外的Java FX屏幕 [英] Java FX out of the window screen
问题描述
我想更改数字变量会没事,但是增加时,按钮会从窗口中消失.如何解决?还有如何将标准降低到"10 $"的水平,以便它们位于同一行?
I wanna it will be okay when the number variables is changed, but when the are increased the button goes out from the window. How to fix it? Also how to put the bar down to the level of "10$", so they will be in the same row?
之前:
之后:
这是我的代码:
VBox vboxBottom = new VBox();
HBox hboxBottomElements = new HBox(15);
HBox hboxBottomMain = new HBox(0);
Region region = new Region();
region.setPrefWidth(500);
hboxBottomElements.getChildren().addAll(visaLabel, separator2, adLabel, separator3, governRelationStatus, separator4, region, next);
hboxBottomElements.setPadding(new Insets(5));
vboxBottom.getChildren().addAll(separator1, new Group(hboxBottomElements));
vboxBottom.setPadding(new Insets(3));
hboxBottomMain.getChildren().addAll(new Group(moneyBox), vboxBottom);
hboxBottomMain.setPadding(new Insets(3));
layout.setBottom(hboxBottomMain);
推荐答案
在此处使用Group
vboxBottom.getChildren().addAll(separator1, new Group(hboxBottomElements));
您正在创建一个布局结构,该结构将hboxBottomElements
的大小调整为首选大小,而与可用空间无关.
如果可用空间不足,HBox
只是将元素移出其边界的右侧.这意味着如果包含moneyBox
的Group
增大,则Button
将移出HBox
...
you're creating a layout structure that resizes hboxBottomElements
to it's prefered size independent of the space available.
HBox
simply moves elements out the right side of it's bounds, if the space available does not suffice. This means if the Group
containing moneyBox
grows, the Button
is moved out of the HBox
...
下面的简单示例演示了该行为:
The following simpler example demonstrates the behavior:
@Override
public void start(Stage primaryStage) {
Button btn = new Button("Do something");
HBox.setHgrow(btn, Priority.NEVER);
btn.setMinWidth(Region.USE_PREF_SIZE);
Region filler = new Region();
filler.setPrefWidth(100);
HBox.setHgrow(filler, Priority.ALWAYS);
Rectangle rect = new Rectangle(200, 50);
HBox hBox = new HBox(rect, filler, btn);
Scene scene = new Scene(hBox);
primaryStage.setScene(scene);
primaryStage.show();
}
这将调整filler
的大小以使HBox
适合窗口.
This will resize filler
to make the HBox
fit the window.
现在替换
Scene scene = new Scene(hBox);
使用
Scene scene = new Scene(new Group(hBox));
和Button
将移出窗口...
这篇关于窗口外的Java FX屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!