How to convert JTextField to String and String to JTextField?

前端 未结 4 1049
余生分开走
余生分开走 2020-12-20 19:00

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

4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-20 19:30

    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

提交回复
热议问题