Skip to main content

adding text/label to stage during runtime

2 replies [Last post]
Joined: 2009-11-05

hi people, i would like to add text/label to the stage in JAVAFX using the arraylist which contain the data from database.
what i want to do can be written in this format using JAVA

//Java coding

//JAVAFX coding

var textboxes : Text[];
var searchBtn = Button {
layoutInfo: LayoutInfo { width: 100 height: 50 } // overrides preferred size
translateX:10 translateY:140

onMouseClicked:function(e) {
label.fill= Color.WHITE;

var dataSource= new DataSource();
var aryArtefact = new ArrayList();
var objname : String;
var ite:Iterator;

aryArtefact = dataSource.GetDetails();

ite =aryArtefact.listIterator();

artefact as Artefact;
insert Text{
fill: Color.WHITE
x:1000 y:1000
font: Font { size: 10 }
content: artefact.getAccessionNo()
}into textboxes;


objname = artefact.getObjName();
label.content =objname;
// textboxes[0].content= artefact.getAccessionNo();

this is the stage code

public function run() {
var stg = Stage {
title:"Hong Kong Archeology Archiaval"
style: StageStyle.UNDECORATED
scene: Scene {
width: 799
height: 532
fill: Color.BLACK
content: [
bg,xImg//Bacground Images and X Cursor
]//End Content
}//End Scene
}//End Stage
}//End Run

sorry for my bad english. if you are unable to understand my question do feel free to ask me .
any help will be appreciated. for your information i am able to print out the data while looping the arraylist
but the stage wont have this textboxes which i created while looping the arraylist. any solution for me so the stage will have those textboxes?bg,xImg,label,Txtsearch,searchBtn all this is able to show in the stage

Message was edited by: xclaim

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2007-11-15

Looks like you forgot to bind the content of the scene. Without that, changes in the sequence textboxes, will not be reflected in the scene. Try the following code:

scene: Scene {
content: bind [bg, xImg,label,Txtsearch,searchBtn,textboxes]

Joined: 2009-11-05

haha never mind it ok thanks for the help
i managed to solve it.
by the way do u know any solution like displaying swf files in javaFX or having a datagrid with paging for javaFX