Reputation: 1841
I am trying to pass an output to a text area.
I have Class Search
which handles all the searching and display the output using System.out.println()
.
I have created Class GUI
in order to make the console output (System.out.println())
appear in the JTextArea
.
I am trying to pass that data into the text area using objects but I dont know why it is not working.
Class Search
has this method that calculates the output:
public static void searchIndex(String searchString) throws IOException, ParseException
Class GUI
has the text1
In Class GUI I have tried this:
text1.setText(Search.searchIndex(searchString));
but it is giving me an error searchString cannot be resolved to a variable
Any suggestions ?
Regards.
Upvotes: 0
Views: 675
Reputation: 20442
searchString cannot be resolved to a variable
The above error is caused by the fact that you are trying to use the variable "searchString" without declaring it.
String searchString = "Some string that is in the search index";
text1.setText(Search.searchIndex(searchString));
Upvotes: 0
Reputation: 51030
The method is not returning:
public static void searchIndex(String searchString) throws IOException, ParseException {
Need to change void
to String
and also return the result:
public static String searchIndex(String searchString) throws IOException, ParseException {
//do search
return resultString;
}
For the following to work:
text1.setText(Search.searchIndex(searchString));
Upvotes: 2