Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert JTextField to String and String to JTextField?

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

like image 880
user733046 Avatar asked May 06 '11 05:05

user733046


People also ask

Which of the following method is used to get the string from JTextField?

The JTextField offers a getText() and a setText() method - those are for getting and setting the content of the text field.


1 Answers

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

like image 155
Harry Joy Avatar answered Sep 21 '22 01:09

Harry Joy