0

I am somewhat at a loss here because I've been trying various changes and nothing will help this work. The JDialog will not pop up, much less update the progress bar at the same time. I have also tried to use a ProgressMonitor, to no avail. Is this an issue I can circumvent?

SftpDialog object:

public SftpDialog(Component parent) {
    jd = this;
    EventQueue.invokeLater(new Runnable() {

        @Override
        public void run() {
            setModalityType(ModalityType.APPLICATION_MODAL);
            setTitle("Progress");
            setResizable(false);
            setBounds(100, 100, 450, 300);  
            getContentPane().setLayout(null);

            lblTxt1.setHorizontalAlignment(SwingConstants.CENTER);
            lblTxt1.setBounds(10, 159, 424, 14);
            getContentPane().add(lblTxt1);

            progressBar.setBounds(10, 222, 424, 14);
            getContentPane().add(progressBar);
            setVisible(true);
        }
    });
}

@Override
public boolean count(long count) {
    EventQueue.invokeLater(new Runnable() {
        @Override
        public void run() {
            progressBar.setValue((int) count);
            lblTxt1.setText(dec.format(count) + "B / " + pb);
        }
    });
    return true;
}

@Override
public void end() {
    EventQueue.invokeLater(new Runnable() {
        @Override
        public void run() {
            if(jd != null) {
                jd.dispose();
            }
        }
    });
}

@Override
public void init(int op, String src, String dest, long max) {
    EventQueue.invokeLater(new Runnable() {
        @Override
        public void run() {
            pb = dec.format(max) + "B";
            progressBar.setMaximum((int) max);
        }
    });
}

Executing class:

SftpDialog sftpA = new SftpDialog(main);
SftpDialog sftpB = new SftpDialog(main);

sftp = JavaMarketplace.ftp.getSftpChannel();
sftp.put(new ByteArrayInputStream(json.getBytes("UTF-8")), sftp.getHome() + "/Data/Software/" + name.replace(" ", "") + ".json", sftpA);
if(priceInCents == 0) {
    sftp.put(f.getPath(), sftp.getHome() + "/Data/Software/" +  name.replace(" ", "") + ".jar", sftpB);
}else {

}
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • 1
    Start by taking a look at [Concurrency in Swing](https://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html) and [Worker Threads and SwingWorker](https://docs.oracle.com/javase/tutorial/uiswing/concurrency/worker.html) – MadProgrammer Jun 15 '18 at 05:22
  • And in case the links of @MadProgrammer don't work for you (they should), note: For better help sooner, post a [MCVE] or [Short, Self Contained, Correct Example](http://www.sscce.org/). And a general tip: Java GUIs have to work on different OS', screen size, screen resolution etc. using different PLAFs in different locales. As such, they are not conducive to pixel perfect layout. Instead use layout managers, or [combinations of them](http://stackoverflow.com/a/5630271/418556) along with layout padding and borders for [white space](http://stackoverflow.com/a/17874718/418556). – Andrew Thompson Jun 15 '18 at 06:10

0 Answers0