0

I want to get data from this API: http://countryapi.gear.host/v1/Country/getCountries. I need that user can write name of the Country in JTextField and get NativeName and CurrencyCode in JTextArea.

I have such a code, it returns data only for Country which I write in HttpGet: HttpGet request = new HttpGet("http://countryapi.gear.host/v1/Country/getCountries?pName=Australia");.

But how can I do that user can write the Country and get info for it which he wants?

3
  • Well, instead of always sending "Australia", send what the text field contains. Commented Dec 1, 2017 at 20:04
  • yes, but how can I do this? Commented Dec 1, 2017 at 20:06
  • By calling getText() on the text field. docs.oracle.com/javase/tutorial/uiswing/components/… Commented Dec 1, 2017 at 20:06

1 Answer 1

1

Try to use this

request = new HttpGet(
        "http://countryapi.gear.host/v1/Country/getCountries?pName=country"
                .replaceAll("country", yourTextField.getText())
);
Sign up to request clarification or add additional context in comments.

1 Comment

Or use Apache URIBuilder to build... look here: stackoverflow.com/questions/9907161/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.