我正在与允许我使用指纹扫描仪的 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
}