How to convert JTextField to String and String to JTextField?

user733046 picture user733046 · May 6, 2011 · Viewed 105.2k times · Source

How to convert JTextField to String and String to JTextField in Java?

Answer

Harry Joy picture Harry Joy · May 6, 2011

how to convert JTextField to string and string to JTextField in java

If you mean how to get and set String from jTextField then you can use following methods:

String str = jTextField.getText() // get string from jtextfield

and

jTextField.setText(str)  // set string to jtextfield
//or
new JTextField(str)     // set string to jtextfield

You should check JavaDoc for JTextField