How do i convert a string data type to JTextField type. I have set of text boxes in a window and i want to fill it from database using a loop. I am constructing a string with the content same as text box name and now i want to change the data type to JTextField.
---EDIT----
private void formWindowOpened(java.awt.event.WindowEvent evt) {
try {
int p_id = made_up.p_id;
String sql = "SELECT * FROM pos_metrics WHERE p_id='" + p_id + "'";
ResultSet rs = mysql_query.execute_mysql(variables.con.conn, sql);
int i = 1;
while (rs.next()) {
Object metricss = "metrics1" + i;
Object metricss2 = "metrics2_" + i;
Object values = "value" + i;
JTextField text1;
JTextField text2;
JTextField text3;
text1 = (JTextField) metricss;
text2 = (JTextField) metricss2;
text3 = (JTextField) values;
text1.setText(rs.getString("pos_metrics1"));
text2.setText(rs.getString("pos_metrics2"));
text3.setText(rs.getString("pos_value"));
i++;
}
} catch (SQLException ex) {
Logger.getLogger(unit_builder.class.getName()).log(Level.SEVERE, null, ex);
}
}
This is my code and i am getting error on the line where i change the type..