java - QR 扫描仪时间

标签 java mysql swing

我使用的是 zxing core 1.7、zxing j2se 1.7 和网络摄像头捕获 0.3.11 库

可能IDE是netbeans 7.2,数据库是mysql

问题是线程....我似乎无法创建一个标识符来中断并将其跳转到另一个方法...而且我认为我做得非常错误... 有任何想法吗 ? 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);
 }

最佳答案

我自己找到了答案..呵呵 将结果设置为 int 并获取长度将不起作用...... 您只会在 if 参数中指出它...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);



}

关于java - QR 扫描仪时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32934852/

相关文章:

java - 在一个项目中使用Aspectj编译时编织和Java编译时注释处理

Java - EC2 实例的 HTTPS GET 调用因握手失败而失败,在本地工作

php - 允许创建自定义字段的最佳方式

php - 仅从 MYSQL 更新语句中选择列名的函数

java - 使用向上/向下键导航后,jTable 的行号错误

java - 从 dotnet 客户端连接到 java 服务器时收到 "java.net.SocketException: Connection reset"

php - MySQL 表中的特殊字符无法正确显示

java - 如何加入现有的 SwingWorker

Java Swing 。从 JButton 打开一个新的 JPanel 并使按钮变得漂亮

java - 将 UTC 中的 ISO 8601 字符串转换为本地时间 - JodaTime 添加与本地时区相反的时间