How can I convert string to label in javafx?
<p>In my project, a have a bunch of labels for some purpose. Since I am able to move them on stackpane using drag, I want to be able to save their new location in my app. So I was thinking about database, with columns for X and Y position, name of the label and its text. </p>

<p>However, since i want to use quite a lot of labels, I didn't want to code load of labels from database one by one, so I used this:</p>

<pre><code>private void button_load(ActionEvent event) {
    try{
     String host = "jdbc:sqlite:C://app/app.sqlite";
         Connection con = DriverManager.getConnection(host);
         PreparedStatement pst = null;
         String SQL = "select * from labels";
         pst=con.prepareStatement(SQL);
         ResultSet rs=pst.executeQuery();

         while(rs.next()){

         String name=rs.getString("Name");
         Double Y=rs.getDouble("Y");
         Double X=rs.getDouble("X");
         String Text=rs.getString("Text");

         name.setLayoutX(X);
         name.setLayoutX(Y);
         name.setText(Text);

        }}

         catch (SQLException ex)        
 {      Logger.getLogger(app.class.getName()).log(Level.SEVERE, null, ex);}}
</code></pre>

<p>Obvious problem is, that I am not allowed to use content of the string ("name" in this case) for further use as label (<code>"string cannot be converted to label"</code>). I have been searching for some solution, but haven't found any.</p>

<p>So I would like to ask, is there a way, how to convert string to label or any other way that would help be in this situation? </p>

<p>Thanks</p>