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 {
}