Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Assigning variables with dynamic names in Javafx level

 
burak dogancay
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Everyone,

I am working on a specific project that includes javafx(visualization) and Java SE.Unfortunately ı couldn't solve one problem

The problem is;

I would like to assign variables with dynamic name like "label1,label2,label3,label4".In this case I wanted to define "label" string and add other numbers automatically near this string using "for loop" (In instance ; "label"+1 , "label"+2, "label"+3 ).

Ofcourse I tried to use "arraylist" and "Hashmap" class.But I dont want to define any integer number to these variables.I just would like to create these variable names dynamically.Because ı will have almost 100 Label and all labels will be assigned like label1,label2,label3,label4,label5......

The reason of not defining any integer numbers to these labels i ; I will use them in java fx scene builder to initialize and set some textfields to them.

My code is;



After getting correct label , I will make : label1.setText(Global.variable.get()); -> it will set Global.variable string value to labe1 ,label2, label3 ................label100

Thank you in advance.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic