これはバグではありません。重いジョブと軽いスイング ジョブを、メイン スレッドの隣のセプレッド スレッドで実行する必要があります。これは、ダイアログ GUI スレッドとその ActionListenerEvents の間のバックラウンドでの重いジョブとの関係の論理的な影響のために必要です。メインスレッドを分離しないと、いくつかの通知イベントのために Swing ドローが決定されます。私は同じ問題を抱えていました.JFrameから開始したFTP Upload Progressの進行状況を監視して、JDialogに表示しようとしました。
最初に試しました:
//Activated by Upload Button
public void actionPerformed(ActionEvent e) {
if("Upload".equals(e.getActionCommand())){
// some Declarations
new Thread(){
public void run() {
/*Run JDialog with the Upload - ProgressBar*/
FileUploadProgressBar fileUploadProgressBar = new FileUploadProgressBar(localFile, remoteFile, ftpPersistence);
}
}.start();
/*Run the heavy weigth Job - the Upload*/
ftpPersistence.uploadFile(localFile, remoteFile);
// ...
}
//...
}
しかし、この方法で JDialog FrameBorder と balck コンテンツ ペインを取得できますが ...
次の試行:
//Activated by Upload Button
public void actionPerformed(ActionEvent e) {
if("Upload".equals(e.getActionCommand())){
// some Declarations
new Thread(){
public void run() {
/*Run JDialog with the Upload - ProgressBar*/
FileUploadProgressBar fileUploadProgressBar = new FileUploadProgressBar(localFile, remoteFile, ftpPersistence);
}
}.start();
new Thread(){
public void run()
/*Run the heavy weigth Job - the Upload*/
ftpPersistence.uploadFile(localFile, remoteFile);
}
}.start();
// ...
}
//...
}
そしてついにそれはうまくいきました、それが助けになることを願っています;)