How to pick up Form value - Java - Swing

Asked

Viewed 1,395 times

2

I created a form on Java interfacing Swing, in this has a field textfield Text and a button Send, in the code of the button need to assign the value informado in the textfield to a variable of the type String, what is the function for this ?

  • Post your code so we can take a look.

  • 2

    String str = textField.getText(); If I understand correctly, I believe that this already solves.

  • @Diegofelipe What is the reason of (String), is some data conversion ?

  • I corrected, as per java documentation in this case do not need to cast, it already brings straight as string.

  • @Diegofelipe I will test as soon as possible.

1 answer

2


  • No problem. I did not answer directly because I wanted to wait for the OP to show if the problem was simple anyway. Anyway, your answer is valid :)

  • 1

    @Diegofelipe, it was like this: the object - JTextField texto = new JTextField(); the variable - String textoaux = texto.getText();, thank you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.