fxml文件在OS X中的行为不符合预期

时间:2016-05-09 06:13:23

标签: macos javafx javafx-2

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

<?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中,当我启动应用程序时,应用程序窗口没有按预期显示,但它在左上角显示为一个小窗口。

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

这是我的进度条形码: -

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;
    }

1 个答案:

答案 0 :(得分:0)

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