connet.lolipop.jp
FXMLファイル
● ボタンやラベルなどの部品を配置し、JavaFXGUIアプリケーション作成のベースとなる XMLコード形式で記述するドキュメントファイルです。

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

<?import javafx.scene.control.Menu?>
<?import javafx.scene.control.MenuBar?>
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.control.SeparatorMenuItem?>
<?import javafx.scene.layout.BorderPane?>

<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sceneapp.controller.RootController">
   <top>
      <MenuBar BorderPane.alignment="CENTER">
        <menus>
          <Menu mnemonicParsing="false" text="ファイル">
            <items>
              <MenuItem mnemonicParsing="false" onAction="#siteExit" text="閉じる" />
            </items>
          </Menu>
          <Menu mnemonicParsing="false" text="編集">
            <items>
              <MenuItem mnemonicParsing="false" text="検索" />
            </items>
          </Menu>
          <Menu mnemonicParsing="false" text="ヘルプ">
            <items>
              <MenuItem mnemonicParsing="false" onAction="#siteAbout" text="サイトについて" />
              <SeparatorMenuItem mnemonicParsing="false" />
              <MenuItem mnemonicParsing="false" onAction="#siteVersion" text="バージョン情報" />
            </items>
          </Menu>
        </menus>
      </MenuBar>
   </top>
</BorderPane> 

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

<?import javafx.scene.control.Hyperlink?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?>

<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sceneapp.controller.IndexController">
    <children>      
      <Label alignment="CENTER" layoutX="50.0" prefHeight="53.0" prefWidth="501.0" text="ここは画面1です(スタート)">
         <font>
            <Font size="36.0" />
         </font>
      </Label>
      <Hyperlink layoutX="20.0" layoutY="300.0" onAction="#viewAction" text="画面2へ移動" />
      <Hyperlink layoutX="20.0" layoutY="329.0" onAction="#view2Action" text="画面3へ移動" />
   </children>
</AnchorPane>

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

<?import javafx.scene.control.Hyperlink?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?>

<AnchorPane id="label2Action" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sceneapp.controller.IndexController">
   <children>
      <Label alignment="CENTER" layoutX="155.0" prefHeight="53.0" prefWidth="278.0" text="ここは画面2です">
         <font>
            <Font size="36.0" />
         </font>
      </Label>
      <Hyperlink layoutX="20.0" layoutY="300.0" onAction="#view2Action" text="画面3へ移動" />
      <Hyperlink layoutX="20.0" layoutY="329.0" onAction="#indexAction" text="画面1へ移動" />
    </children>
</AnchorPane>

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

<?import javafx.scene.control.Hyperlink?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?>

<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sceneapp.controller.IndexController">
   <children>
      <Label alignment="CENTER" contentDisplay="CENTER" layoutX="155.0" prefHeight="53.0" prefWidth="278.0" text="ここは画面3です">
         <font>
            <Font size="36.0" />
         </font>
      </Label>
      <Hyperlink layoutX="20.0" layoutY="300.0" onAction="#viewAction" text="画面2へ移動" />
      <Hyperlink layoutX="20.0" layoutY="329.0" onAction="#indexAction" text="画面1へ移動" />     
   </children>
</AnchorPane>

Search
Google


↟ このページの先頭へ