首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >在JavaFX中的窗格之间切换

在JavaFX中的窗格之间切换
EN

Stack Overflow用户
提问于 2013-04-24 02:35:25
回答 1查看 41.1K关注 0票数 27

我正在尝试用JavaFX编写一个使用FXML的Java程序。然而,我在布局管理方面遇到了问题。我想要在窗格之间切换,就像我习惯于在swing中使用CardLayout一样,但我似乎无法实现。

我用谷歌搜索了一下,没有找到任何答案。

在JavaFX中有没有CardLayout的等价物?如果是这样,你能给我举个例子吗?那会对我的晚上有很大的帮助!

以下是我的FXML代码

    <AnchorPane id="anchorPane" prefHeight="324.0" prefWidth="530.0" xmlns:fx="http://javafx.com/fxml" fx:controller="javafxapplication2.SampleController">
  <children>
    <Pane fx:id="mainScreen" layoutX="6.0" prefHeight="324.0" prefWidth="518.0">
      <children>
        <Button layoutX="254.0" layoutY="37.0" mnemonicParsing="false" text="Button" />
      </children>
    </Pane>
    <Pane fx:id="loginScreen" prefHeight="324.0" prefWidth="530.0">
      <children>
        <TextField id="password" fx:id="username" layoutX="142.0" layoutY="106.0" prefWidth="200.0" />
        <TextField fx:id="password" layoutX="142.0" layoutY="140.0" prefWidth="200.0" />
        <Label fx:id="label" layoutX="126.0" layoutY="120.0" minHeight="16.0" minWidth="69.0" />
        <Button fx:id="button" layoutX="213.0" layoutY="196.0" onAction="#handleButtonAction" onKeyPressed="#handleButtonAction" text="Login" />
      </children>
    </Pane>
  </children>
</AnchorPane>
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16176701

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档