![](/img/trans.png)
[英]How to use a swing timer to wait 1 second before continuing to execute code?
[英]How to wait for setIcon() method to execute before resuming the code?
我有這樣的代碼:
jLabel.setIcon(map);
Graphics2D g = (Graphics2D) jLabel.getGraphics();
g.drawPolygon(xpoints,ypoints,vpolygonpointsarray.length);
但是發生的是,在更新標簽圖標之前先繪制了多邊形。 我懷疑設置圖標會創建新線程。 我想等到圖標設置好后再執行其余代碼。 我該怎么做?
您應該使用覆蓋的繪制方法( paint()
, paintComponents()
等)進行自定義繪制代碼。 在這里檢查: http : //docs.oracle.com/javase/tutorial/uiswing/painting/step2.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.