My current code looks like this:
final String[] value = new String[1];
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
value[0] = textArea.getText();
}
});
The use of a final array seems like a bit of a hack. Is there a more elegant solution?
I ve done a lot of searching, but I don t seem to be able to find anything to do this, which surprises me. Although I keep coming across SwingWorker
, but I m not sure that s suitable in this case?
I m assuming that JTextArea.getText()
isn t thread-safe.
Thanks.