2012-02-11 4 views
3

EDIT 私はScrollBarではなく "ScrollPane"を探していました。javafx2でFXMLを使用してScrollBarを作成するにはどうすればよいですか?

<ScrollPane fitToWidth="true" fx:id="sasd"> 
<content> 
    <VBox prefWidth="200" alignment="center" fx:id="Left"> 
     <children> 
      <Label alignment="center" fx:id="gcProgramLine" text="g0x100 y123 z23"/> 

すべてがうまくいきます。

私は..私は "スクロール" する能力を有することのVBoxを希望するには多くのラベルを追加したいのVBoxを持っていますこれらの行が追加されます。

これは私のFXMLの外観です。そのBorderPane ..しかし、私は無関係な部分を省略しました。

<left> 
    <VBox prefWidth="200" alignment="center" fx:id="Left"> 
     <children> 
      <ScrollBar orientation="VERTICAL" fx:id="sasd"> 
       <children> 
      <Label alignment="center" fx:id="gcProgramLine" text="g0x100 y123 z23"/> 
      <Label alignment="center" fx:id="gcProgramLine" text="g0x121 y13 z23"/> 
      <Label alignment="center" fx:id="gcProgramLine" text="g0x10 y113 z23"/> 
      <Label alignment="center" fx:id="gcProgramLine" text="g0x100 y123 z23"/> 
      <Label alignment="center" fx:id="gcProgramLine" text="g0x100 y123 z23"/> 
      <Label alignment="center" fx:id="gcProgramLine" text="g0x100 y123 z23"/> 
      <Label alignment="center" fx:id="gcProgramLine" text="g0x100 y123 z23"/> 
      <Label alignment="center" fx:id="gcProgramLine" text="g0x100 y123 z23"/> 
      <Label alignment="center" fx:id="gcProgramLine" text="g0x121 y13 z23"/> 
      <Label alignment="center" fx:id="gcProgramLine" text="g0x10 y113 z23"/> 
      <Label alignment="center" fx:id="gcProgramLine" text="g0x100 y123 z23"/> 
      </children> 
      </ScrollBar> 
     </children> 
    </VBox> 

しかし、これでエラーが発生し、コンパイルされて動作しません。私は子供たちも取り除こうとしました。幸運はない..どんな考え? Javafx 2.0で "FXML"のやり方を見つけるのは難しいです。コードを使用するのはかなり簡単です...

答えて

4

ScrollPaneは、childrenという属性を持たず、Nodecontentを持っています。次のFXMLはあなたのために動作します:

<ScrollPane fx:id="sasd"> 
    <content> 
     <VBox prefWidth="200" alignment="center" fx:id="Left"> 
      <children> 
       <Label alignment="center" fx:id="gcProgramLine" text="g0x100 y123 z23"/> 
       <Label alignment="center" fx:id="gcProgramLine" text="g0x121 y13 z23"/> 
       <Label alignment="center" fx:id="gcProgramLine" text="g0x10 y113 z23"/> 
       <Label alignment="center" fx:id="gcProgramLine" text="g0x100 y123 z23"/> 
       <Label alignment="center" fx:id="gcProgramLine" text="g0x100 y123 z23"/> 
       <Label alignment="center" fx:id="gcProgramLine" text="g0x100 y123 z23"/> 
       <Label alignment="center" fx:id="gcProgramLine" text="g0x100 y123 z23"/> 
       <Label alignment="center" fx:id="gcProgramLine" text="g0x100 y123 z23"/> 
       <Label alignment="center" fx:id="gcProgramLine" text="g0x121 y13 z23"/> 
       <Label alignment="center" fx:id="gcProgramLine" text="g0x10 y113 z23"/> 
       <Label alignment="center" fx:id="gcProgramLine" text="g0x100 y123 z23"/> 
      </children> 
     </VBox> 
    </content> 
</ScrollPane> 
+3

一つは 'ScrollPane'は' Pane'のサブクラスですが、それはないと思われるでしょう。代わりに階層(Java 8の場合)は 'ScrollPane'です。<' Region' <'Parent' <' Node'(<は拡張されています)です。これらのクラスは保護されたメソッド 'Parent#getChildren()'をとり、 'Pane'のようにpublicにしません。 –

関連する問題