2015-10-04 114 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); 



}