我與一個允許使用指紋掃描器的JNI進行交互。我寫的代碼將掃描的ByteBuffer解析成JNI,並將其轉換爲BufferedImage進行保存。在線程中獲取和設置標誌變量
我無法弄清楚的是如何在我的GUI上的jlabel圖標嘗試更新之前等待掃描線程完成。最簡單的方法是什麼?
我還需要添加什麼?
編輯:
//Scanner class
Thread thread = new Thread() {
public void run() {
// [...] get ByteBuffer and Create Image code
try {
File out = new File("C:\\Users\\Desktop\\print.png");
ImageIO.write(padded, "png", out);
// [???] set flag here
} catch (IOException e) {
e.printStackTrace();
}
}
};
thread.start();
return true;
//Gui class
private void btnScanPrintActionPerformed(java.awt.event.ActionEvent evt) {
Scanner scanPrint = new Scanner();
boolean x = scanPrint.initDevice();
//Wait for the scanning thread to finish the Update the jLabel here to show
//the fingerprint
}
你可以顯示掃描線程內運行的代碼(的相關部分)嗎? – mthmulders