fxml文件在OS X中的行为不符合预期 [英] fxml file not behaving as expected in OS X

查看:152
本文介绍了fxml文件在OS X中的行为不符合预期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用fxml文件来创建我的java fx UI。
文件是: -

I am using an fxml file to to create my java fx UI. the file is:-

<?import java.lang.String?>
<?import javafx.collections.FXCollections?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?>

<AnchorPane fx:id="ap" maxHeight="1.7976931348623157E308"
    maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity"
    prefHeight="480.0" prefWidth="840.0" xmlns="http://javafx.com/javafx/8.0.65"
    xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.Buildsapp.Main.BuildsController">
    <children>
        <VBox prefHeight="200.0" prefWidth="100.0"
            AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
            AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
            <children>
                <HBox alignment="CENTER_LEFT" spacing="20.0" VBox.vgrow="NEVER">
                    <padding>
                        <Insets bottom="12.0" left="12.0" right="12.0" top="12.0" />
                    </padding>
                    <children>
                        <GridPane hgap="10.0" HBox.hgrow="NEVER">
                            <columnConstraints>
                                <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" />
                                <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" />
                                <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" />
                                <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" />
                                <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" />
                                <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" />
                                <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" />
                            </columnConstraints>
                            <rowConstraints>
                                <RowConstraints minHeight="10.0" vgrow="SOMETIMES" />
                                <RowConstraints minHeight="10.0" prefHeight="30.0"
                                    vgrow="SOMETIMES" />
                            </rowConstraints>
                            <children>
                                <Label prefHeight="21.0" prefWidth="88.0" text="Platform" />
                                <ComboBox fx:id="versionCombo" prefHeight="31.0"
                                    prefWidth="108.0" GridPane.rowIndex="1">
                                    <items>
                                        <FXCollections fx:factory="observableArrayList">
                                            <String fx:value="Win" />
                                            <String fx:value="Mac" />
                                        </FXCollections>
                                    </items>
                                    <value>
                                        <String fx:value="Mac" />
                                    </value>
                                </ComboBox>
                                <Label prefHeight="21.0" prefWidth="80.0" text="Product"
                                    GridPane.columnIndex="1" />
                                <ComboBox fx:id="verCombo" prefHeight="31.0" prefWidth="127.0"
                                    promptText="build" GridPane.columnIndex="1" GridPane.rowIndex="1">
                                    <items>
                                        <FXCollections fx:factory="observableArrayList">
                                            <String fx:value="build" />
                                            <String fx:value="build2" />
                                        </FXCollections>
                                    </items>

                                </ComboBox>
                                <Label text="Version" GridPane.columnIndex="2" />
                                <ComboBox fx:id="versionNo" prefHeight="31.0"
                                    prefWidth="109.0" GridPane.columnIndex="2" GridPane.rowIndex="1" />
                                <Label prefHeight="21.0" prefWidth="60.0" text="Server"
                                    GridPane.columnIndex="3" />
                                <ComboBox fx:id="locCombo" prefHeight="31.0" prefWidth="103.0"
                                    GridPane.columnIndex="3" GridPane.rowIndex="1">
                                    <items>
                                        <FXCollections fx:factory="observableArrayList">
                                            <String fx:value="SJ" />
                                            <String fx:value="MN" />
                                        </FXCollections>
                                    </items>
                                    <value>
                                        <String fx:value="SJ" />
                                    </value>
                                </ComboBox>
                                <Button fx:id="downloadButton" minWidth="80.0"
                                    mnemonicParsing="false" text="Download" GridPane.columnIndex="4"
                                    GridPane.rowIndex="1" />
                                <Button fx:id="installButton" minWidth="80.0"
                                    mnemonicParsing="false" text="Install" GridPane.columnIndex="5"
                                    GridPane.rowIndex="1" />
                                <Button fx:id="locButton" mnemonicParsing="false"
                                    prefHeight="31.0" prefWidth="120.0" text="Open Folder"
                                    GridPane.columnIndex="6" GridPane.rowIndex="1" />
                            </children>
                        </GridPane>
                    </children>
                </HBox>
                <TableView fx:id="tableView" VBox.vgrow="ALWAYS">
                    <columns>
                        <TableColumn fx:id="builds" prefWidth="482.0" text="Builds" />
                        <TableColumn fx:id="date" minWidth="0.0" prefWidth="500.0"
                            text="Date" />
                    </columns>
                </TableView>
            </children>
        </VBox>

    </children>
</AnchorPane>

它在Windows中工作正常,当我启动应用程序时,应用程序窗口没有按预期显示但它在左上角显示为一个小窗口。

It works fine in windows while in mac when I launch the app the app window does not appear as expected but it appears as a small window on the top left corner.

类似的问题出现在我正在使用的进度对话框中,它可以在Windows中正常工作但在mac中( OS X)当应用程序扩展时,就像应用程序窗口大小最大时,进度对话框也覆盖了整个显示屏幕,而我已经给出了固定大小的场景窗口。

The similar issue is appearing with the progress dialog which I am using it works fine in Windows but in mac(OS X) when the app is expanded like when app window size is maximum the progress dialog is also covering the whole display screen while I have given fixed size to scene window.

这是我的进度条形码: -

This is my progress bar code:-

public ProgressBar startProgressBar() {
        primaryStage = new Stage();
        ProgressBar pb = new ProgressBar(0);
        //ProgressIndicator pi = new ProgressIndicator(0);
        //pi.progressProperty().bind(pb.progressProperty());
        HBox hb = new HBox();
        hb.setSpacing(5);
        hb.setAlignment(Pos.CENTER);
        hb.getChildren().addAll(pb);
        Scene scene = new Scene(hb, 300, 100);
        primaryStage.setScene(scene);
        primaryStage.setTitle("Downloading Build...");
        primaryStage.show();
        return pb;
    }


推荐答案

我能找到解决方案对于第一个可以解决的问题,我将锚面板的minHight和minWidth修复为fxml文件中的某个值而不是无穷大,但我仍然无法找到第二个问题的解决方案。

I am able find the solution for the first issue that can be solved my fixing the minHight and minWidth of the anchor panel to some value in fxml file instead of infinity but I am still not able to find the solution for the second issue.

这篇关于fxml文件在OS X中的行为不符合预期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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