我想在滚动事件上缩放窗格中的所有节点.
到目前为止我尝试了什么:
当我执行scaleX或scaleY时,窗格的边框分别缩放(在设置窗格样式时看到-fx-border-color: black;).因此,如果我不是从窗格的边界开始,并非每个事件都会启动,所以我需要它.
下一步我试图扩展每个节点,结果非常糟糕,就像这样 - (通过点延伸的线条).或者如果在另一侧滚动,则会更少
我尝试的另一种方法是缩放Node的点.它更好,但我不喜欢它.它看起来
point.setScaleX(point.getScaleX()+scaleX)和y和其他节点适当.
是否有任何方法可以使全屏(如果可能的话也调整大小)而不是重新排列所有内容(实际上它的作用是重新排列元素,如调整大小但是整个屏幕)以制作实际的全屏模式?(比如通常做的游戏就是更改屏幕分辨率),因此按钮和文本会根据屏幕/窗口的大小而增长
另外如何删除消息和效果点击"esc"键退出全屏模式?
编辑:使用这种方式使可调整大小
@Override public void start(Stage stage) throws Exception{
final int initWidth = 720; //initial width
final int initHeight = 1080; //initial height
final Pane root = new Pane(); //necessary evil
Pane controller = new CtrlMainMenu(); //initial view
controller.setPrefWidth(initWidth); //if not initialized
controller.setPrefHeight(initHeight); //if not initialized
root.getChildren().add(controller); //necessary evil
Scale scale = new Scale(1, 1, 0, 0);
scale.xProperty().bind(root.widthProperty().divide(initWidth)); //must match with the one in the controller
scale.yProperty().bind(root.heightProperty().divide(initHeight)); //must match with the one in the controller
root.getTransforms().add(scale);
final Scene scene …Run Code Online (Sandbox Code Playgroud) 我想让我的申请流畅.但是,当我将窗口放大时,与UI元素相比,字体看起来很小.最终,当我调整窗口大小时,我希望文本的大小变大或变小.我知道理论上我可以用style属性来做这个,但是在某些情况下我已经将该属性绑定到了其他东西.
我知道还有的"fontProperty"的方法,但我没有将其绑定到,因为我无法弄清楚如何创建一个同步的大小动态OBJECTPROPERTY.我该怎么办?
编辑:为了避免混淆,我试图根据其他因素改变字体大小,而不是相反.
我正在尝试使用Javafx制作屏幕键盘进行布局.我正在使用Scene Builder制作FXML文件.
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.paint.*?>
<?import javafx.scene.text.*?>
<AnchorPane id="AnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="186.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2">
<children>
<VBox layoutX="0.0" layoutY="0.0" prefHeight="186.0" prefWidth="600.0" rotate="0.0" spacing="2.0">
<children>
<HBox minHeight="33.0" prefHeight="33.0" prefWidth="600.0" spacing="2.0">
<children>
<Label maxWidth="-Infinity" prefHeight="33.0" prefWidth="35.0" text="Milk" textAlignment="CENTER" />
<Label maxWidth="-Infinity" prefHeight="33.0" text="Mister" />
<Label maxWidth="-Infinity" prefHeight="35.0" text="Minimum" />
</children>
<padding>
<Insets left="5.0" />
</padding>
</HBox>
<HBox prefHeight="29.0" prefWidth="600.0">
<children>
<Button minWidth="29.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="29.0" text="Esc" textAlignment="CENTER" underline="false"> …Run Code Online (Sandbox Code Playgroud)