摆动窗口不可见

时间:2014-10-18 05:45:27

标签: java swing

我很新,请帮助我。 我正在研究拇指扫描仪sdk。 当我正在调试代码时,它会卡在frame.setvisible(true)并且我的摇摆窗口没有出现。

我从我的主要方法

中调用它
public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                JFrame_CSD200_FpCaptureAccess frame = new JFrame_CSD200_FpCaptureAccess();

                frame.setVisible(true);

                //frame.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
} 

然后我的调试器转到

public JFrame_CSD200_FpCaptureAccess()
{
    setResizable(false);
    init();
}

这是init方法

public void init()
{       
    OutputStream out = new OutputStream() {
        @Override
        public void write(int b) throws IOException {
            updateTextArea(String.valueOf((char) b));
        }

        @Override
        public void write(byte[] b, int off, int len) throws IOException {
            updateTextArea(new String(b, off, len));
        }

        @Override
        public void write(byte[] b) throws IOException {
            write(b, 0, b.length);
        }
    };

    System.setOut(new PrintStream(out, true));
    System.setErr(new PrintStream(out, true));
    System.out.print("Hello");

    setIconImage(Toolkit.getDefaultToolkit().getImage(JFrame_CSD200_FpCaptureAccess.class.getResource("/img/3M_Logo.gif")));

    dialog = null;
    fingerprintCaptureApi = new mmm.cogent.fpCaptureApi.MMMCogentCSD200DeviceImpl(); 
    fingerprintCaptureApi.initDevice();

    fp1BMPBytes = null;
    fp1BMPBytes = null;
    fp1FMRBytes = null;
    fp2FMRBytes = null;

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);


    setBounds(100, 100, 765, 622);
    contentPane = new JPanel();
    contentPane.setBackground(Color.WHITE);
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(null);

    lblCaptureImg = new JLabel("");
    lblCaptureImg.setBounds(68, 120, 114, 172);
    lblCaptureImg.setBorder(new LineBorder(Color.black));
    contentPane.add(lblCaptureImg);

    btnInitialize = new JButton("Initialize");
    btnInitialize.setBounds(28, 315, 105, 23);
    btnInitialize.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {

            setDisplayedImageByteArray(null);
            repaint();      

            Thread initThread = new Thread( new initWorker() );
            initThread.setDaemon(true);
            initThread.start();
        }

    });
    btnInitialize.setFont(new Font("Tahoma", Font.PLAIN, 11));
    contentPane.add(btnInitialize);

    btnCapture = new JButton("Capture");
    btnCapture.setBounds(28, 349, 105, 23);
    btnCapture.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            setDisplayedImageByteArray(null);
            repaint();

            System.out.println("isDeviceConnected: "+ fingerprintCaptureApi.isDeviceConnected());
            System.out.println("isDeviceInitialized: "+ fingerprintCaptureApi.isDeviceInitialized());

            if(fingerprintCaptureApi.isDeviceConnected()) //&& fingerprintCaptureApi.isDeviceInitialized()
            {
                Random random = new Random(Calendar.getInstance().getTimeInMillis());
                currentSessionId = random.nextInt();
                fingerprintCaptureApi.startCapture(new CaptureCallbackImpl(), currentSessionId, 30);
            }
        }
    });
    btnCapture.setFont(new Font("Tahoma", Font.PLAIN, 11));
    contentPane.add(btnCapture);

    btnAbort = new JButton("Abort");
    btnAbort.setBounds(251, 349, 105, 23);
    btnAbort.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int ret = fingerprintCaptureApi.cancelCapture();
            if (  ret < 0){
                System.out.println("Abort Failed. Error Code: " +ret);
            }
            else{
                System.out.println("Capture Aborted.");
                /*while(!captureFinished){
                    try {
                        Thread.sleep(150);
                    } catch (InterruptedException ex) {
                        // TODO Auto-generated catch block
                        //e.printStackTrace();
                    }
                }*/
                setDisplayedImageByteArray(null);
                repaint();
            }           
        }
    });
    btnAbort.setFont(new Font("Tahoma", Font.PLAIN, 11));
    contentPane.add(btnAbort);

    btnForceCapture = new JButton("Force Capture");
    btnForceCapture.setBounds(139, 349, 105, 23);
    btnForceCapture.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {

            setDisplayedImageByteArray(null);
            repaint();

            fingerprintCaptureApi.forceCapture();
        }
    });
    btnForceCapture.setFont(new Font("Tahoma", Font.PLAIN, 11));
    contentPane.add(btnForceCapture);

    btnDeviceInfo = new JButton("Device Info");
    btnDeviceInfo.setBounds(139, 383, 105, 23);
    btnDeviceInfo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            if(fingerprintCaptureApi.isDeviceInitialized())
            {                   
                DeviceInfo devInfo = fingerprintCaptureApi.getDeviceInfo();
                if(devInfo == null)
                {
                    JOptionPane.showMessageDialog(null,"Unable to fetch data.Please try again.");
                }
                else
                {
                    JOptionPane.showMessageDialog(null,"Version: " + devInfo.getFirmwareVersion() + "\nModel: " + devInfo.getModel()
                            + "\nSerial No: " + devInfo.getSerialNumber() );
                }
            }
            else
            {
                JOptionPane.showMessageDialog(null,"Device Information Not Found.Please Initialize Device.");
            }
        }
    });
    btnDeviceInfo.setFont(new Font("Tahoma", Font.PLAIN, 11));
    contentPane.add(btnDeviceInfo);

    btnDeinit = new JButton("DeInit");
    btnDeinit.setBounds(251, 315, 105, 23);
    btnDeinit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int ret = fingerprintCaptureApi.deinitDevice();
            if (  ret < 0){
                System.out.println("De-init Failed. Error Code: " +ret);
            }
            else{
                System.out.println("De-Initialized.");
                resetAll();                 
                repaint();
            }
        }
    });
    btnDeinit.setFont(new Font("Tahoma", Font.PLAIN, 11));
    contentPane.add(btnDeinit);

    btnSaveBmpImage = new JButton("Save BMP Image");        
    btnSaveBmpImage.setBounds(207, 185, 124, 23);
    btnSaveBmpImage.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            if(getDisplayedImageByteArray() != null)
            {
                JFileChooser jfc = new JFileChooser("./");
                FileNameExtensionFilter filter = new FileNameExtensionFilter("Bitmap Images", "bmp");
                jfc.setFileFilter(filter);

                int retVal = jfc.showSaveDialog(btnSaveBmpImage);

                if(retVal == JFileChooser.APPROVE_OPTION)
                {
                    try{
                        FileOutputStream fos = null;
                        try {
                            fos = new FileOutputStream(jfc.getSelectedFile());

                            byte[] byteArray = getDisplayedImageByteArray();
                            if(byteArray != null){
                                fos.write(getDisplayedImageByteArray());
                            }

                        } catch (FileNotFoundException ex) {
                            // TODO Auto-generated catch block
                            //e.printStackTrace();
                        }
                        fos.close();
                    } catch (IOException exIO) {
                        // TODO Auto-generated catch block
                        //e.printStackTrace();
                    }catch (NullPointerException npe) {
                        // TODO Auto-generated catch block
                        //e.printStackTrace();
                    }           
                }
            }
            else
            {
                JOptionPane.showMessageDialog(null, "No images to save");
            }
        }
    });
    btnSaveBmpImage.setFont(new Font("Tahoma", Font.PLAIN, 11));
    contentPane.add(btnSaveBmpImage);

    btnSaveRawImage = new JButton("Save Raw Image");
    btnSaveRawImage.setBounds(207, 219, 124, 23);
    btnSaveRawImage.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            if(getDisplayedImageByteArray() != null)
            {
                JFileChooser jfc = new JFileChooser("./");
                FileNameExtensionFilter filter = new FileNameExtensionFilter("Raw Images", "raw");
                jfc.setFileFilter(filter);

                int retVal = jfc.showSaveDialog(btnSaveRawImage);

                if(retVal == JFileChooser.APPROVE_OPTION)
                {
                    try{
                        FileOutputStream fos = null;
                        try {
                            fos = new FileOutputStream(jfc.getSelectedFile());

                            byte[] rawBytes = bmpToRaw(getDisplayedImageByteArray());
                            if(rawBytes != null){
                                fos.write(rawBytes);
                            }

                        } catch (FileNotFoundException ex) {
                            // TODO Auto-generated catch block
                            //e.printStackTrace();
                        }
                        fos.close();
                    } catch (IOException exIO) {
                        // TODO Auto-generated catch block
                        //e.printStackTrace();
                    }catch (NullPointerException npe) {
                        // TODO Auto-generated catch block
                        //e.printStackTrace();
                    }           
                }
            }
            else
            {
                JOptionPane.showMessageDialog(null, "No images to save");
            }
        }
    });
    btnSaveRawImage.setFont(new Font("Tahoma", Font.PLAIN, 11));
    contentPane.add(btnSaveRawImage);

    lblFpImg1 = new JLabel("");
    lblFpImg1.setBounds(477, 120, 100, 150);
    lblFpImg1.setBorder(new LineBorder(Color.black));
    contentPane.add(lblFpImg1);

    lblFpImg2 = new JLabel("");
    lblFpImg2.setBounds(597, 120, 100, 150);
    lblFpImg2.setBorder(new LineBorder(Color.black));
    contentPane.add(lblFpImg2);

    btnMatchFingerprints = new JButton("Match Fingerprints");
    btnMatchFingerprints.setBounds(533, 310, 133, 23);
    btnMatchFingerprints.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {

            if(fp1FMRBytes != null && fp2FMRBytes != null)
            {
                boolean bMatch = fingerprintCaptureApi.matchIso19794_2Templates(fp1FMRBytes, fp2FMRBytes);

                if(bMatch == true)
                {
                    JOptionPane.showMessageDialog(btnMatchFingerprints, "Matched.","",JOptionPane.ERROR_MESSAGE);
                }
                else
                {
                    JOptionPane.showMessageDialog(btnMatchFingerprints, "Not Matched.","",JOptionPane.INFORMATION_MESSAGE);
                }   
            }
            else
            {
                JOptionPane.showMessageDialog(null, "Unable to match two fingers.");
            }



        }
    });
    btnMatchFingerprints.setFont(new Font("Tahoma", Font.PLAIN, 11));
    contentPane.add(btnMatchFingerprints);

    ButtonGroup radioBtnGrp = new ButtonGroup();

    rbFp1 = new JRadioButton("FingerPrint - 1");
    rbFp1.setBounds(477, 275, 100, 23);
    rbFp1.setSelected(true);
    rbFp1.setFont(new Font("Tahoma", Font.PLAIN, 11));
    rbFp1.setBackground(Color.WHITE);
    radioBtnGrp.add(rbFp1);
    contentPane.add(rbFp1);

    rbFp2 = new JRadioButton("FingerPrint - 2");
    rbFp2.setBounds(597, 275, 100, 23);
    rbFp2.setFont(new Font("Tahoma", Font.PLAIN, 11));
    rbFp2.setBackground(Color.WHITE);
    radioBtnGrp.add(rbFp2);
    contentPane.add(rbFp2);

    //lblLogo = new JLabel(new ImageIcon(JFrame_CSD200_FpCaptureAccess.class.getResource("/img/3M_Logo.gif")));
    //lblLogo = new JLabel("");
    lblLogo = new JLabel(new ImageIcon(Toolkit.getDefaultToolkit().getImage(JFrame_CSD200_FpCaptureAccess.class.getResource("/img/3M_Logo.gif")).toString()));

    lblLogo.setBounds(10, 10, 95, 64);
    contentPane.add(lblLogo);

    lblmCogentCsd = new JLabel("3M Cogent CSD200 FpCaptureAccess");
    lblmCogentCsd.setBounds(207, 33, 401, 29);
    lblmCogentCsd.setHorizontalAlignment(SwingConstants.CENTER);
    lblmCogentCsd.setForeground(Color.BLACK);
    lblmCogentCsd.setFont(new Font("Tahoma", Font.BOLD, 14));
    contentPane.add(lblmCogentCsd);

    JButton btnCalibrate = new JButton("Calibrate");
    btnCalibrate.setBounds(139, 315, 105, 23);
    btnCalibrate.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {            

            if(fingerprintCaptureApi.isDeviceInitialized())
            {               
                Thread calibrateThread = new Thread( new calibrateWorker() );
                calibrateThread.setDaemon(true);
                calibrateThread.start();
            }
            else
            {
                JOptionPane.showMessageDialog(null,"Please Initialize Device");
            }
        }
    });
    btnCalibrate.setFont(new Font("Tahoma", Font.PLAIN, 11));
    contentPane.add(btnCalibrate);

    textArea = new JTextArea();
    textArea.setBounds(366, 237, 80, 160);
    textArea.setEditable(false);
    textArea.setBorder(new LineBorder(Color.black));

    JScrollPane scrollPane = new JScrollPane(textArea);
    scrollPane.setBounds(10, 417, 720, 172);
    scrollPane.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS );         
    scrollPane.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS );
    contentPane.add(scrollPane);

    lblNfiq1 = new JLabel("");
    lblNfiq1.setHorizontalAlignment(SwingConstants.CENTER);
    lblNfiq1.setFont(new Font("Tahoma", Font.BOLD, 11));
    lblNfiq1.setBounds(477, 95, 100, 14);
    contentPane.add(lblNfiq1);

    lblNfiq2 = new JLabel("");
    lblNfiq2.setHorizontalAlignment(SwingConstants.CENTER);
    lblNfiq2.setFont(new Font("Tahoma", Font.BOLD, 11));
    lblNfiq2.setBounds(597, 95, 100, 14);
    contentPane.add(lblNfiq2);

    this.setLocationRelativeTo(null);
}

当我的光标到达frame.setvisible(true)时,它会卡在那里。我不知道我在哪里做错了。 任何帮助将不胜感激。

由于

1 个答案:

答案 0 :(得分:-1)

尝试在init方法中仅使用setVisible(true)作为最后一个成员...并将其从EventQueue run()方法中删除

public void init()
{       
    OutputStream out = new OutputStream() {
        @Override
        public void write(int b) throws IOException {
            updateTextArea(String.valueOf((char) b));
        }

        @Override
        public void write(byte[] b, int off, int len) throws IOException {
            updateTextArea(new String(b, off, len));
        }

        @Override
        public void write(byte[] b) throws IOException {
            write(b, 0, b.length);
        }
    };

    System.setOut(new PrintStream(out, true));
    System.setErr(new PrintStream(out, true));
    System.out.print("Hello");

    setIconImage(Toolkit.getDefaultToolkit().getImage(JFrame_CSD200_FpCaptureAccess.class.getResource("/img/3M_Logo.gif")));

    dialog = null;
    fingerprintCaptureApi = new mmm.cogent.fpCaptureApi.MMMCogentCSD200DeviceImpl(); 
    fingerprintCaptureApi.initDevice();

    fp1BMPBytes = null;
    fp1BMPBytes = null;
    fp1FMRBytes = null;
    fp2FMRBytes = null;

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);


    setBounds(100, 100, 765, 622);
    contentPane = new JPanel();
    contentPane.setBackground(Color.WHITE);
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(null);

    lblCaptureImg = new JLabel("");
    lblCaptureImg.setBounds(68, 120, 114, 172);
    lblCaptureImg.setBorder(new LineBorder(Color.black));
    contentPane.add(lblCaptureImg);

    btnInitialize = new JButton("Initialize");
    btnInitialize.setBounds(28, 315, 105, 23);
    btnInitialize.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {

            setDisplayedImageByteArray(null);
            repaint();      

            Thread initThread = new Thread( new initWorker() );
            initThread.setDaemon(true);
            initThread.start();
        }

    });
    btnInitialize.setFont(new Font("Tahoma", Font.PLAIN, 11));
    contentPane.add(btnInitialize);

    btnCapture = new JButton("Capture");
    btnCapture.setBounds(28, 349, 105, 23);
    btnCapture.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            setDisplayedImageByteArray(null);
            repaint();

            System.out.println("isDeviceConnected: "+ fingerprintCaptureApi.isDeviceConnected());
            System.out.println("isDeviceInitialized: "+ fingerprintCaptureApi.isDeviceInitialized());

            if(fingerprintCaptureApi.isDeviceConnected()) //&& fingerprintCaptureApi.isDeviceInitialized()
            {
                Random random = new Random(Calendar.getInstance().getTimeInMillis());
                currentSessionId = random.nextInt();
                fingerprintCaptureApi.startCapture(new CaptureCallbackImpl(), currentSessionId, 30);
            }
        }
    });
    btnCapture.setFont(new Font("Tahoma", Font.PLAIN, 11));
    contentPane.add(btnCapture);

    btnAbort = new JButton("Abort");
    btnAbort.setBounds(251, 349, 105, 23);
    btnAbort.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int ret = fingerprintCaptureApi.cancelCapture();
            if (  ret < 0){
                System.out.println("Abort Failed. Error Code: " +ret);
            }
            else{
                System.out.println("Capture Aborted.");
                /*while(!captureFinished){
                    try {
                        Thread.sleep(150);
                    } catch (InterruptedException ex) {
                        // TODO Auto-generated catch block
                        //e.printStackTrace();
                    }
                }*/
                setDisplayedImageByteArray(null);
                repaint();
            }           
        }
    });
    btnAbort.setFont(new Font("Tahoma", Font.PLAIN, 11));
    contentPane.add(btnAbort);

    btnForceCapture = new JButton("Force Capture");
    btnForceCapture.setBounds(139, 349, 105, 23);
    btnForceCapture.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {

            setDisplayedImageByteArray(null);
            repaint();

            fingerprintCaptureApi.forceCapture();
        }
    });
    btnForceCapture.setFont(new Font("Tahoma", Font.PLAIN, 11));
    contentPane.add(btnForceCapture);

    btnDeviceInfo = new JButton("Device Info");
    btnDeviceInfo.setBounds(139, 383, 105, 23);
    btnDeviceInfo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            if(fingerprintCaptureApi.isDeviceInitialized())
            {                   
                DeviceInfo devInfo = fingerprintCaptureApi.getDeviceInfo();
                if(devInfo == null)
                {
                    JOptionPane.showMessageDialog(null,"Unable to fetch data.Please try again.");
                }
                else
                {
                    JOptionPane.showMessageDialog(null,"Version: " + devInfo.getFirmwareVersion() + "\nModel: " + devInfo.getModel()
                            + "\nSerial No: " + devInfo.getSerialNumber() );
                }
            }
            else
            {
                JOptionPane.showMessageDialog(null,"Device Information Not Found.Please Initialize Device.");
            }
        }
    });
    btnDeviceInfo.setFont(new Font("Tahoma", Font.PLAIN, 11));
    contentPane.add(btnDeviceInfo);

    btnDeinit = new JButton("DeInit");
    btnDeinit.setBounds(251, 315, 105, 23);
    btnDeinit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int ret = fingerprintCaptureApi.deinitDevice();
            if (  ret < 0){
                System.out.println("De-init Failed. Error Code: " +ret);
            }
            else{
                System.out.println("De-Initialized.");
                resetAll();                 
                repaint();
            }
        }
    });
    btnDeinit.setFont(new Font("Tahoma", Font.PLAIN, 11));
    contentPane.add(btnDeinit);

    btnSaveBmpImage = new JButton("Save BMP Image");        
    btnSaveBmpImage.setBounds(207, 185, 124, 23);
    btnSaveBmpImage.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            if(getDisplayedImageByteArray() != null)
            {
                JFileChooser jfc = new JFileChooser("./");
                FileNameExtensionFilter filter = new FileNameExtensionFilter("Bitmap Images", "bmp");
                jfc.setFileFilter(filter);

                int retVal = jfc.showSaveDialog(btnSaveBmpImage);

                if(retVal == JFileChooser.APPROVE_OPTION)
                {
                    try{
                        FileOutputStream fos = null;
                        try {
                            fos = new FileOutputStream(jfc.getSelectedFile());

                            byte[] byteArray = getDisplayedImageByteArray();
                            if(byteArray != null){
                                fos.write(getDisplayedImageByteArray());
                            }

                        } catch (FileNotFoundException ex) {
                            // TODO Auto-generated catch block
                            //e.printStackTrace();
                        }
                        fos.close();
                    } catch (IOException exIO) {
                        // TODO Auto-generated catch block
                        //e.printStackTrace();
                    }catch (NullPointerException npe) {
                        // TODO Auto-generated catch block
                        //e.printStackTrace();
                    }           
                }
            }
            else
            {
                JOptionPane.showMessageDialog(null, "No images to save");
            }
        }
    });
    btnSaveBmpImage.setFont(new Font("Tahoma", Font.PLAIN, 11));
    contentPane.add(btnSaveBmpImage);

    btnSaveRawImage = new JButton("Save Raw Image");
    btnSaveRawImage.setBounds(207, 219, 124, 23);
    btnSaveRawImage.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            if(getDisplayedImageByteArray() != null)
            {
                JFileChooser jfc = new JFileChooser("./");
                FileNameExtensionFilter filter = new FileNameExtensionFilter("Raw Images", "raw");
                jfc.setFileFilter(filter);

                int retVal = jfc.showSaveDialog(btnSaveRawImage);

                if(retVal == JFileChooser.APPROVE_OPTION)
                {
                    try{
                        FileOutputStream fos = null;
                        try {
                            fos = new FileOutputStream(jfc.getSelectedFile());

                            byte[] rawBytes = bmpToRaw(getDisplayedImageByteArray());
                            if(rawBytes != null){
                                fos.write(rawBytes);
                            }

                        } catch (FileNotFoundException ex) {
                            // TODO Auto-generated catch block
                            //e.printStackTrace();
                        }
                        fos.close();
                    } catch (IOException exIO) {
                        // TODO Auto-generated catch block
                        //e.printStackTrace();
                    }catch (NullPointerException npe) {
                        // TODO Auto-generated catch block
                        //e.printStackTrace();
                    }           
                }
            }
            else
            {
                JOptionPane.showMessageDialog(null, "No images to save");
            }
        }
    });
    btnSaveRawImage.setFont(new Font("Tahoma", Font.PLAIN, 11));
    contentPane.add(btnSaveRawImage);

    lblFpImg1 = new JLabel("");
    lblFpImg1.setBounds(477, 120, 100, 150);
    lblFpImg1.setBorder(new LineBorder(Color.black));
    contentPane.add(lblFpImg1);

    lblFpImg2 = new JLabel("");
    lblFpImg2.setBounds(597, 120, 100, 150);
    lblFpImg2.setBorder(new LineBorder(Color.black));
    contentPane.add(lblFpImg2);

    btnMatchFingerprints = new JButton("Match Fingerprints");
    btnMatchFingerprints.setBounds(533, 310, 133, 23);
    btnMatchFingerprints.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {

            if(fp1FMRBytes != null && fp2FMRBytes != null)
            {
                boolean bMatch = fingerprintCaptureApi.matchIso19794_2Templates(fp1FMRBytes, fp2FMRBytes);

                if(bMatch == true)
                {
                    JOptionPane.showMessageDialog(btnMatchFingerprints, "Matched.","",JOptionPane.ERROR_MESSAGE);
                }
                else
                {
                    JOptionPane.showMessageDialog(btnMatchFingerprints, "Not Matched.","",JOptionPane.INFORMATION_MESSAGE);
                }   
            }
            else
            {
                JOptionPane.showMessageDialog(null, "Unable to match two fingers.");
            }



        }
    });
    btnMatchFingerprints.setFont(new Font("Tahoma", Font.PLAIN, 11));
    contentPane.add(btnMatchFingerprints);

    ButtonGroup radioBtnGrp = new ButtonGroup();

    rbFp1 = new JRadioButton("FingerPrint - 1");
    rbFp1.setBounds(477, 275, 100, 23);
    rbFp1.setSelected(true);
    rbFp1.setFont(new Font("Tahoma", Font.PLAIN, 11));
    rbFp1.setBackground(Color.WHITE);
    radioBtnGrp.add(rbFp1);
    contentPane.add(rbFp1);

    rbFp2 = new JRadioButton("FingerPrint - 2");
    rbFp2.setBounds(597, 275, 100, 23);
    rbFp2.setFont(new Font("Tahoma", Font.PLAIN, 11));
    rbFp2.setBackground(Color.WHITE);
    radioBtnGrp.add(rbFp2);
    contentPane.add(rbFp2);

    //lblLogo = new JLabel(new ImageIcon(JFrame_CSD200_FpCaptureAccess.class.getResource("/img/3M_Logo.gif")));
    //lblLogo = new JLabel("");
    lblLogo = new JLabel(new ImageIcon(Toolkit.getDefaultToolkit().getImage(JFrame_CSD200_FpCaptureAccess.class.getResource("/img/3M_Logo.gif")).toString()));

    lblLogo.setBounds(10, 10, 95, 64);
    contentPane.add(lblLogo);

    lblmCogentCsd = new JLabel("3M Cogent CSD200 FpCaptureAccess");
    lblmCogentCsd.setBounds(207, 33, 401, 29);
    lblmCogentCsd.setHorizontalAlignment(SwingConstants.CENTER);
    lblmCogentCsd.setForeground(Color.BLACK);
    lblmCogentCsd.setFont(new Font("Tahoma", Font.BOLD, 14));
    contentPane.add(lblmCogentCsd);

    JButton btnCalibrate = new JButton("Calibrate");
    btnCalibrate.setBounds(139, 315, 105, 23);
    btnCalibrate.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {            

            if(fingerprintCaptureApi.isDeviceInitialized())
            {               
                Thread calibrateThread = new Thread( new calibrateWorker() );
                calibrateThread.setDaemon(true);
                calibrateThread.start();
            }
            else
            {
                JOptionPane.showMessageDialog(null,"Please Initialize Device");
            }
        }
    });
    btnCalibrate.setFont(new Font("Tahoma", Font.PLAIN, 11));
    contentPane.add(btnCalibrate);

    textArea = new JTextArea();
    textArea.setBounds(366, 237, 80, 160);
    textArea.setEditable(false);
    textArea.setBorder(new LineBorder(Color.black));

    JScrollPane scrollPane = new JScrollPane(textArea);
    scrollPane.setBounds(10, 417, 720, 172);
    scrollPane.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS );         
    scrollPane.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS );
    contentPane.add(scrollPane);

    lblNfiq1 = new JLabel("");
    lblNfiq1.setHorizontalAlignment(SwingConstants.CENTER);
    lblNfiq1.setFont(new Font("Tahoma", Font.BOLD, 11));
    lblNfiq1.setBounds(477, 95, 100, 14);
    contentPane.add(lblNfiq1);

    lblNfiq2 = new JLabel("");
    lblNfiq2.setHorizontalAlignment(SwingConstants.CENTER);
    lblNfiq2.setFont(new Font("Tahoma", Font.BOLD, 11));
    lblNfiq2.setBounds(597, 95, 100, 14);
    contentPane.add(lblNfiq2);

    this.setLocationRelativeTo(null);
    this.setVisible(true); <------------------------Add it here instead of `run()`

}