2015-10-04 174 views
0

我使用的是斑馬線的核心1.7,斑馬線J2SE 1.7和攝像頭捕捉0.3.11庫QR掃描時間

可能是IDE的NetBeans 7.2和myqsl數據庫

問題是線程。 ...我似乎無法做出一個標識符打破並跳轉到另一種方法...我認爲即時通訊做得很錯... 任何想法? T_T

public void run() { 
    do { 
     try { 
      Thread.sleep(300); 
     } catch (InterruptedException e) {} 
     Result result = null; 
     BufferedImage image = null; 
     if (webcam.isOpen()) { 
      if ((image = webcam.getImage()) == null) { 
       continue; 
      } 
      LuminanceSource source = new BufferedImageLuminanceSource(image); 
      BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); 
      try { 
       result = new MultiFormatReader().decode(bitmap); 
      } catch (NotFoundException e) { 
      } 
     } 
     int a; 
     a = (result.getText().length()); //thread error 
     if (result != null) { 
      txtID.setText(result.getText()); 
      try { 
       QRLOAD(); 
      } catch (Exception e) {} //method to load jtable   
      try { 
       Update_PIC(); 
      } catch (Exception e) {} //method to load picture jlabel 
      try { 
       Time_inUP(); 
      } //method to to update the time 
      catch (Exception e) {} 
      if (a > 1) { 
       OperatorQR(); //method to close the thread and call the main panel 
      } else { 
      } 
     } 
    } while (true); 
} 
+0

請解釋你的意思是'做一個標識符來打破和跳躍它.. .. –

+0

@ redflar3 確定即時通訊不好,無論從條款....我生成一個QR碼..值是1位數。 ...所以它很容易掃描...掃描它會產生一個jtextfield鍵的值釋放..生成jtable視圖,然後是圖片方法... 我似乎不能阻止它或停止它來驗證它......它直接去操作符方法殺死窗口......我想我需要一個標識符或說明符,使第一次嘗試趕上返回其結果和只能由操作符的方法結束... – Javamanadiktus

+0

我嘗試將結果轉換爲int給出線程錯誤「CaptureCode.run(CaptureCode.java:817)」 – Javamanadiktus

回答

0

我我自己想通了answer..hehe 設置的結果作爲一個int和獲得的長度將無法正常工作...... 你只表明它在當參數... T_T

public void run() { 

    do { 

    try { 


      Thread.sleep(300); 
     } catch (InterruptedException e) { 
     } 

     Result result = null; 
     BufferedImage image = null; 

     if (webcam.isOpen()) { 

      if ((image = webcam.getImage()) == null) { 
       continue; 
      } 

      LuminanceSource source = new BufferedImageLuminanceSource(image); 
      BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); 

      try { 

       result = new MultiFormatReader().decode(bitmap); 



      } catch (NotFoundException e) { 



      } 

     } 


     if (result != null ) { 


           txtID.setText(result.getText()); 




             try{QRLOAD();} //method to load jtable 
             catch(Exception e){ }     

           try{Update_PIC();}   //method to load picture jlabel 
            catch(Exception e){ } 


           try{Time_inUP();}  //method to to update the time 
          catch(Exception e){ }  

         try{Update_PIC();} 
          catch(Exception e){ }   

           try{QRLOAD();} 
          catch(Exception e){ } 




           if (result.getText().length()>1) {// This is the solution 


           OperatorQR(); //method to close the thread,webcam and call the main panel 

    } 

        } 


    }while (true); 



}