Tópicos e jtable
Eu tenho um problema com o jtable.
Eu tenho um número de threads e cada um deles tem que adicionar uma linha ao jTable, mas a tabela permanece vazia. Estou trabalhando com netbeans, os gráficos são totalmente separados da lógica. Alguém pode me ajudar, por favor?
este é o código que eu uso para adicionar uma linha
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) {
}