Eclipse 4.4ではじめる Javaプログラミング入門 Eclipse 4.4 Luna対応

JavaFXによるGUIプログラミング - コントロールを活用する

Icon comment count 0
Icon stock count 0

3.2.13GridPaneの利用

コントロール類を縦横に綺麗に整列して配置したい場合に用いられるのがGridPaneです。これは、ペイン全体を格子状に切り分け、それぞれの部分にコントロールをはめ込んで表示します。

これも、実物を見たほうが早いでしょう。

リスト3.15 window.fxml(書き換える部分)
<GridPane prefHeight="150.0" prefWidth="300.0" 
  xmlns="http://javafx.com/javafx/8" 
  xmlns:fx="http://javafx.com/fxml/1" 
  fx:controller="jp.tuyano.eclipsebook.WindowController">
  <Button text="Button1" 
    GridPane.columnIndex="0" GridPane.rowIndex="0"/>
  <Button text="Button2" 
    GridPane.columnIndex="1" GridPane.rowIndex="1"/>
  <Button text="Button3"
     GridPane.columnIndex="2" GridPane.rowIndex="2"/>
</GridPane>
図3.34GridPaneを使い、3つのButtonを縦横に1ずつ移動して配置する。

コメント

    コメントはありません