2008年12月17日水曜日

JavaFX UI Elements の配置

横配置には HBox、縦配置には VBox を使う

button1,button2,button3 を横に並べる
  1. HBox{  
  2.   translateX: 10  
  3.   translateY: 10  
  4.   spacing: 20  
  5.   content:[button1,button2,button3]  
  6. }  

translateX, translateY は HBox のゼロ点をずらす
spacing は各コンテンツの間隔
content は並べるコンテンツの Sequence

button1,button2,button3 を縦に並べる
  1. VBox{  
  2.   translateX: 10  
  3.   translateY: 10  
  4.   spacing: 20  
  5.   content:[button1,button2,button3]  
  6. }  

Stage で使うとこんな感じ
More...
  1. import javafx.stage.Stage;  
  2. import javafx.scene.Scene;  
  3. import javafx.scene.layout.HBox;  
  4. import javafx.scene.layout.VBox;  
  5. import javafx.scene.paint.Color;  
  6.   
  7. Stage {  
  8.   title: "Components"  
  9.   width: 430   
  10.   height: 300  
  11.   visible: true  
  12.   scene: Scene{    
  13.      fill: Color.CORNSILK  
  14.      content: VBox{  
  15.         translateX: 10  
  16.         translateY: 10  
  17.         spacing: 20  
  18.         content:[  
  19.            HBox{  
  20.              spacing: 50   
  21.              content:[combobox, checkbox]  
  22.            },  
  23.            HBox{  
  24.              spacing: 10  
  25.              content:[  
  26.                 scrollpane,  
  27.                 VBox{  
  28.                    spacing: 50   
  29.                    content:[   
  30.                       VBox{  
  31.                          spacing: bind slider.value   
  32.                          content:[  
  33.                             radioButton1,   
  34.                             radioButton2,   
  35.                             radioButton3]  
  36.                       },   
  37.                       textField]  
  38.                 },  
  39.                 VBox{content:[   
  40.                     button1,   
  41.                     button2,   
  42.                     button3]  
  43.                 }     
  44.              ]  
  45.            },  
  46.            HBox {  
  47.               spacing: 20   
  48.               content:[label, slider]  
  49.            }  
  50.         ]  
  51.      } //VBox  
  52.   }//Scene  
  53. }//Stage  

0 件のコメント:

コメントを投稿