2012-11-15 3 views
0

jtable에 문제가 있습니다.스레드 및 jtable

나는 많은 수의 스레드가 있으며 각 스레드는 jTable에 행을 추가해야하지만 테이블은 비어 있습니다. netbeans 함께 일하고, 그래픽 완전히 논리에서 별도로 있습니다. 누군가 나를 도울 수 있습니까?


제가

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) { 
    } 
+0

문제가 발생했습니다 (테이블은 비어 있습니다), 코드 도움 코드를 제공해주십시오. –

+1

@mav를 사용하면 더 빨리 도움을받을 수 있습니다. [SSCCE] (http://sscce.org/) , 짧은, runable, compilable 스레드에 대한 하드 코드 된 값으로 여기에 다 어두운 수 있습니다. – mKorbel

답변