我有一個Jtree節點代表圖像,用戶可以調用和查看。有時需要將圖像加載四到五秒鐘。理想情況下,我希望在用戶正在等待時顯示等待光標,並選擇樹中選定的節點。然而,我發現用戶點擊節點,沒有任何事情發生,然後出現圖像,然後選擇節點(等待光標從不出現或更可能出現非常短暫,然後立即消失,我試圖重新繪製樹和applet,試圖強制行爲按我想要的順序發生。到目前爲止,我還沒有碰到任何問題。問題:鞦韆更新拼圖
thisApplet.setCursor(new Cursor(Cursor.WAIT_CURSOR));
selectdocumentTreeLeaf(); // a JTree with nodes representing images
tree.repaint();
thisApplet.repaint();
tree.setEnabled(false); //disabled so users don't keep clicking on it.
result = createImage(queue.q[pointer].currentPage); //where the image is fetched
thisApplet.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
有沒有可能在加載圖像時阻塞主Swing線程?圖像加載代碼是否在組件的paint方法中? – Pace 2011-02-09 04:59:55