Use of ListView - UI Control
Thursday Jul 30, 2009
A simple example how ListView works in JavaFX 1.2. I guess it need more feature in next release. But it do basic stuff like providing scrollbar if list is long, selected item actions.Something like this :
Here is the simple code, in which I am adding text array into a ListView(10-15 lines of code). Hmm, image is currently not supported in ListView but soon it will be.
package listviewexample; import javafx.scene.control.ListView; import javafx.scene.Scene; import javafx.scene.text.Font; import javafx.scene.text.Text; import javafx.stage.Stage; import javafx.stage.StageStyle; var te:Text[]; for(i in [0..20]) { var tt = Text { font : Font { size: 24 } x: 10, y: 30 content: "HelloWorld{i}" } insert tt into te; } var simpleList : ListView = ListView { translateX: 0 translateY: 0 height: 330 width: 240 }; for(i in [0..20]) insert te[i].content into simpleList.items; Stage { title: "Simple List" width: 240 height: 325 style: StageStyle.TRANSPARENT scene: Scene { content: [ simpleList ] } }
For some fancy use of ListView, you can see Rakesh Tweeter application on /samples page. Or Josh "A custom virtual list" on jfxstudio.org. Some UI control make life easy.















Just added my own blog this month. I need some ins...
thanks you very very much.thanks you very very muc...