Threads und jtable

Ich habe ein Problem mit jtable.

Ich habe eine Reihe von Threads und jeder muss der jTable eine Zeile hinzufügen, aber die Tabelle bleibt leer. Ich arbeite mit Netbeans, die Grafiken sind völlig unabhängig von der Logik. Kann mir bitte jemand helfen?

Dies ist der Code, den ich zum Hinzufügen einer Zeile verwende

MainGui.java

public void addToTable(String from, String to, int request, int response, String timeElapsed) {
    Object [][] temp = new Object [data.length + 1][5];

    for (int i = 0; i < data.length; i++) {
        for (int j = 0; j < 5; j++) {
            temp[i][j] = data[i][j];
        }
    }

    temp[data.length][0] = from;
    temp[data.length][1] = to;
    temp[data.length][2] = request;
    temp[data.length][3] = response;
    temp[data.length][4] = timeElapsed;

    data = temp;
    table.setModel(new DefaultTableModel(data, columnName));
}

MyThread.java

public void run() {
    try {
        MainGui mg = new MainGui();
        mg.addtotable("null", "null", 0, 0, "null");
    } catch (Exception e) {
    }

Antworten auf die Frage(6)

Ihre Antwort auf die Frage