I've run in to some troubles and couldn't really find an answere.
I need to often add Strings to a TextArea. The Strings come from other classes/objects.
My idea:
@FXML
private static TextArea TAactivity;
public static void activity(String s) {
    TAactivity.appendText(s);
}
and write to it from other classes with:
MainController.activity("Random stuff");
What am I doing wrong?
Greetings
//Edit
public class Main extends Application {
private final int PORT = 4000;
private final String SERVER = "127.0.0.1";
public static Client client;
@Override
public void start(Stage primaryStage) throws Exception{
    client = new Client(SERVER, PORT);
    Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
    primaryStage.setTitle("JJFTP Client");
    primaryStage.setScene(new Scene(root));
    primaryStage.show();
  }
}
public class Client {
private String server;
private int port;
public Client(String s, int p) throws InterruptedException, IOException {
    server = s;
    port = p;
}
public String messagefromserver() throws IOException {
    Controller.c.activity("Waiting for message from server");
    StringBuilder sb;
    Socket socket = new Socket(server, port);
    DataInputStream ASCIIin = new DataInputStream(socket.getInputStream());
    int inputlength = ASCIIin.readInt();
    sb = new StringBuilder();
    for (int i = 0; i < inputlength; i++) {
        int temp = ASCIIin.readInt();
        if (temp < 0) {
            throw new IllegalArgumentException();
        }
        sb.append((char) temp);
    }
    Controller.c.activity("Received -" + sb + "- from server");
    ASCIIin.close();
    socket.close();
    return sb.toString();
  }
}
public class Controller implements Initializable {
public static Controller c;
@FXML
private TextArea TAfiles;
@FXML
private TextField TFcmd;
@FXML
private TextArea TAactivity;
@FXML
public void send() throws Exception {
    String s = TFcmd.getText();
    TFcmd.setText("");
    Main.client.messagetoserver(s);
    String answere = Main.client.messagefromserver();
    if (answere.equals("FILE")) {
        StringBuilder sb = new StringBuilder();
        sb.append(s);
        sb.delete(0, 9);
        Main.client.downloadfile(String.valueOf(sb));
        updatefilelist();
        activity("Filelist updated");
    }
}
public void activity(String s) {
    System.out.println(s);
    TAactivity.setText(TAactivity.getText() + "\n" + s);
}
@Override
public void initialize(URL location, ResourceBundle resources) {
    c=new Controller();
    try {
        updatefilelist();
    } catch (IOException e) {
        e.printStackTrace();
    }
  }
}
There is of course more methods, but I guess not all of them are neccessary. If I remove the static from the objects for Client and or Controller, it says it can not refer to something static from a not static context.
