protected synchronized void setProgress(int a) {

        if (totalBytes > 0) {
            sentBytes += a;
//
//            progBar.setValue(sentBytes);
//
//            //labelBytesSent.setText("Bytes Sent: " + sentBytes + "/" + totalBytes);
//
//            if ((sentBytes * 100) / totalBytes > percentComplete) {
//                percentComplete = (sentBytes * 100) / totalBytes;
//                try {
//                    jso.eval("try{" + postletJS[0] + "(" + percentComplete + ");}catch(e){;}");
//                } catch (netscape.javascript.JSException | NullPointerException ex) {
//                    errorMessage("Unable to send status to Javascript");
//                    msgDiag(ex.getClass().getName() + ": " + ex.getMessage());
//                }
//            }
            if (sentBytes >= totalBytes) {

                if (sentBytes == totalBytes) {
                    // Upload is complete. Check for failed files.
                    if (failedFiles.size() > 0 && failedFileMessage) {
                        // There is at least one failed file. Show an error message
                        String failedFilesString = "\r\n";
                        for (int i = 0; i < failedFiles.size(); i++) {
                            File tempFile = (File) failedFiles.get(i);
                            failedFilesString += tempFile.getName() + "\r\n";
                        }
                        JOptionPane.showMessageDialog(null, pLabels.getLabel(16) + ":" + failedFilesString, pLabels.getLabel(5), JOptionPane.ERROR_MESSAGE);
                    }
                    progCompletion.setText(pLabels.getLabel(2));

                    if (endPageURL != null) {
                        errorMessage("Changing browser page");
                        getAppletContext().showDocument(endPageURL);
                    } else {
//                        try {
//                            // Just ignore this error, as it is most likely from the endpage
//                            // not being set.
//                            // Attempt at calling Javascript after upload is complete.
//                            //errorMessage("Executing: " + postletJS[1] + "();");
//                            //jso.eval("try{" + postletJS[1] + "();}catch(e){;}");
//                        } catch (netscape.javascript.JSException jse) {
//                            // Not to worry, just means the end page and a postletFinished
//                            // method aren't set. Just finish, and let the web page user
//                            // exit the page
//                            //errorMessage("postletFinished, and End page unset");
//                        } catch (NullPointerException ex) {
//                            //errorMessage("postletFinished, and End page unset, and JS not executed");
//                            //msgDiag(ex.getClass().getName() + ": " + ex.getMessage());
//                        }
                    }
                    JOptionPane.showMessageDialog(null, "Sent all", "Sent all", JOptionPane.ERROR_MESSAGE);
                }

                //if (sentBytes > totalBytes) {
                //    JOptionPane.showMessageDialog(null, "sentBytes > totalBytes!!", "sentBytes > totalBytes!!", JOptionPane.ERROR_MESSAGE);
                //}

                // Reset the applet
                totalBytes = 0;
//                percentComplete = 0;
                progBar.setValue(0);
                progBar.repaint();
                files = new File[0];
                tableUpdate();
                buttonAdd.setEnabled(true);
                //help.setEnabled(true);
                if (dropImageURL != null && dropImageUploadURL != null) {
                    iconLabel.setIcon(dropIcon);
                }
                failedFiles.clear();
                uploadedFiles.clear();
                repaint();

            } else {
                //errorMessage("Still not sent all");
            }
        }
    }