簡體   English   中英

為什么此javafx fxml不調整大小?

[英]Why is this javafx fxml does not resize?

我已經下載了免費的SVG,並使用此轉換器將其轉換為fxml。 但是,當我加載fxml並嘗試調整其大小時,它會保持其原始大小。 為什么呢

這是我一次轉換的fxml(只是修改了轉換坐標,因為它給了兩個x / y參數兩個值,而不是一個值):

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

<?import javafx.scene.*?>
<?import javafx.scene.shape.*?>
<?import javafx.scene.paint.*?>
<?import javafx.scene.transform.*?>

<Group id='_root' xmlns:fx="http://javafx.com/fxml" xmlns:fxsvg="http://efxclipse.org/fxml-svg">
    <children>
        <Group
            opacity="1.0"
            id="layer1"
            >
            <children>
                <SVGPath
                    content="m62.695 460.2l-14.737-14.77 3.271-3.09c9.747-9.22 28.802-20.06 44.382-25.24 18.679-6.21 21.399-6.5 62.389-6.62 35.2-0.11 37.99-0.25 45.5-2.29 11.23-3.05 21.43-8.48 29.01-15.42 7.7-7.06 8.17-8.77 2.37-8.77-5.98 0-27.91-4.62-38.38-8.08-12.14-4.02-33.5-14.51-33.5-16.46 0-0.83 3.15-14.09 7-29.46s6.99-28.3 6.97-28.72c-0.01-0.43-3.21-2.8-7.11-5.28-30.93-19.63-42.46-61.82-26.4-96.62 9.66-20.92 23.9-34.9 64.14-62.96 19.59-13.66 36.66-26.79 41.23-31.71l2.33-2.51-4.11-0.69c-5.8-0.98-12.96-6.154-16.52-11.932-2.68-4.354-3.03-5.804-3.03-12.578s0.35-8.224 3.03-12.578c10.05-16.328 32.89-16.328 42.94 0 2.68 4.354 3.03 5.804 3.03 12.578s-0.35 8.224-3.03 12.578c-3.56 5.778-10.72 10.952-16.52 11.932l-4.11 0.69 2.33 2.51c4.57 4.92 21.64 18.05 41.23 31.71 40.24 28.06 54.48 42.04 64.14 62.96 16.06 34.8 4.53 76.99-26.4 96.62-3.9 2.48-7.1 4.85-7.11 5.28-0.02 0.42 3.12 13.35 6.97 28.72s7 28.63 7 29.46c0 1.95-21.36 12.44-33.5 16.46-10.47 3.46-32.4 8.08-38.38 8.08-5.8 0-5.33 1.71 2.37 8.77 7.58 6.94 17.78 12.37 29.01 15.42 7.51 2.04 10.3 2.18 45.5 2.29 31.98 0.09 38.68 0.37 45.5 1.89 19.49 4.33 39.19 13.05 53.38 23.63 12.97 9.68 13.32 7.33-3.68 24.3l-14.73 14.71-5.94-4.44c-15.12-11.32-34.38-19.22-53.53-21.98-5.78-0.83-21.97-1.97-36-2.53-14.02-0.56-29.52-1.72-34.43-2.58-12.87-2.24-26.59-7.08-35.84-12.64-4.43-2.66-8.36-4.84-8.73-4.84s-4.3 2.18-8.73 4.84c-9.25 5.56-22.97 10.4-35.84 12.64-4.91 0.86-20.4 2.02-34.43 2.58-36.43 1.45-51.08 4.01-68.75 11.99-5.298 2.39-17.312 9.86-24.784 15.4-1.933 1.43-2.767 0.77-16.771-13.25z"
                    opacity="1"
                    id="path2496"
                    >
                    <fill>
                        <Color>
                            <red>0.0</red>
                            <green>0.0</green>
                            <blue>0.0</blue>
                        </Color>
                    </fill>
                    <transforms>
                        <Translate
                            x="644.53"
                            y="535.4"
                            >
                        </Translate>
                    </transforms>
                </SVGPath>
                <SVGPath
                    content="m260 226.5v-12.5h12 12v-7.5-7.5h-12-12v-12.5-12.5h-7.5-7.5v12.5 12.5h-12.5-12.5v7.5 7.5h12.5 12.5v12.5 12.5h7.5 7.5v-12.5z"
                    opacity="1"
                    id="path2395"
                    >
                    <fill>
                        <Color>
                            <red>1.0</red>
                            <green>1.0</green>
                            <blue>1.0</blue>
                        </Color>
                    </fill>
                    <transforms>
                        <Translate
                            x="644.53"
                            y="535.4"
                        >
                        </Translate>
                    </transforms>
                </SVGPath>
                <SVGPath
                    content="m205.27 302.48c4.82-1.98 13.15-4.77 18.5-6.2 8.81-2.35 11.48-2.6 28.23-2.6s19.42 0.25 28.23 2.6c7.76 2.07 21.01 6.89 28.28 10.28 0.86 0.4 7.49-10.15 7.49-11.92 0-1.03-9.08-5.26-18.12-8.45-16.43-5.8-27.56-7.65-45.88-7.65s-29.45 1.85-45.88 7.65c-9.04 3.19-18.12 7.42-18.12 8.45 0 1.77 6.63 12.32 7.49 11.92 0.56-0.26 4.96-2.1 9.78-4.08z"
                    opacity="1"
                    id="path2393"
                    >
                    <fill>
                        <Color>
                            <red>1.0</red>
                            <green>1.0</green>
                            <blue>1.0</blue>
                        </Color>
                    </fill>
                    <transforms>
                        <Translate
                            x="644.53"
                            y="535.4"
                            >
                        </Translate>
                    </transforms>
                </SVGPath>
                    <SVGPath
                    content="m185.32 363.13c17.65-12.11 44.18-20.12 66.68-20.12s49.03 8.01 66.68 20.12c2.3 1.58 4.38 2.87 4.63 2.87 0.51 0 8.69-10.68 8.69-11.34 0-1.08-13.52-9.04-23-13.55-23.92-11.38-50.02-15.37-75.68-11.56-14.21 2.11-25.83 5.61-38.32 11.56-9.48 4.51-23 12.47-23 13.55 0 0.66 8.18 11.34 8.69 11.34 0.25 0 2.33-1.29 4.63-2.87z"
                    opacity="1"
                    id="path2391"
                    >
                     <fill>
                        <Color>
                            <red>1.0</red>
                            <green>1.0</green>
                            <blue>1.0</blue>
                        </Color>
                    </fill>
                    <transforms>
                        <Translate
                            x="644.53"
                            y="535.4"
                            >
                        </Translate>
                    </transforms>
                </SVGPath>
            </children>
            <transforms>
                <Translate
                    x="-644.53"
                    y="-535.4"
                    >
                </Translate>
            </transforms>
        </Group>
        <!-- Unhandled type 'SvgMetadataElement' -->
    </children>
</Group>

這是我在其中加載代碼的摘錄:

try {
            Node pieceImage = FXMLLoader.load(getClass().getClassLoader().getResource("chess_bd.fxml"));
            pieceImage.resize(20, 20); // does not work, whatever values are given

為了更完整,我也可以說它是Gluon Mobile項目的一部分,但是我不確定這是“錯誤”點。

Group僅包裝子項並使用其邊界確定其大小。 它不可調整大小。

從javadoc:

Group將承擔其子女的集體責任,並且不能直接調整規模。

此外,由於SVGPath不可調整大小,因此這也不適用於其他布局。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM