What I am trying to accomplish is setting a text field from another thread. my program has a button and when i click it a new thread start running and gets something from a socket afterwards I want to set three text fields according to the data but I can't do it. I've written a method in my mainwindow class to do the .settext()
calls but i cant call the method because I don't even have a reference to my mainwindow instance. how can I properly make updating to my textboxes.
Also a minor question do I have to make my comboboxes final because the compiler complained like that.
Cannot refer to a non-final variable comboBox inside an inner class defined in a different method MainWindow.java
What causes this?
public void run()
{
os.print("INIT {ClassName USARBot."+type.name +"} {Location "+firstPos.x+" , "+firstPos.y+" ,"+firstPos.z+" } {Name "+robotName+"}\r\n");
while (true)
try
{
String str=is.readLine();
String[] substr1=null;
Position p = new Position();
Scanner s=null;
if(str.contains("{Type GroundTruth}"))
substr1=str.split(" ");
s=new Scanner(substr1[8]);
p.x=s.nextDouble();
p.y=s.nextDouble();
p.z=s.nextDouble();
s.close();
//Here I want to set Textfields in MainWindow
} catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}