ファイルを(ADB経由で)Androidタブレットにコピーするアプリケーションがあります。時間がかかるので、不確定なプログレスバーが表示されたポップアップを表示したい。コピー タスクが完了したら、プログレス バーを停止して、ユーザーがダイアログを閉じられるようにしたいと考えています。
現時点では、追加のダイアログ ボックスを追加しておらず、進行状況バーを機能させようとしています。私が抱えている問題は、タスクの開始時に進行状況バーが表示されないことですが、その理由はわかりません. 同期が完了したことを示すダイアログ ボックスが表示されると、進行状況バーが表示されます。コードは次のとおりです。
progress = new JProgressBar(0, 100);
progress.setForeground(new Color(255, 99, 71));
progress.setIndeterminate(true);
progress.setValue(0);
progress.setPreferredSize( new Dimension( 300, 20 ) );
progress.setBounds( 278, 12, 260, 20 );
progress.setVisible(false);
progress.setString("Sync in progress");
progress.setStringPainted(true);
contentPane.add(progress);
pushtotab = new JButton("");
pushtotab.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
if (buildpathset==1){
try{
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
progress.setVisible(true);
wiredsync();
}finally{
JOptionPane.showMessageDialog(null, "sync complete. ",null, buildpathset);
setCursor(Cursor.getDefaultCursor());
progress.setVisible(false);
}}else{
//warning in here later - TO Do
}
}
});
public void wiredsync(){
try {
Process process = Runtime.getRuntime().exec("adb" + " push "+ buildpath + " " + adbtabletsync);
InputStreamReader reader = new InputStreamReader(process.getInputStream());
Scanner scanner = new Scanner(reader);
scanner.close();
int exitCode = process.waitFor();
System.out.println("Process returned: " + exitCode);
} catch(IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}//end
助けてくれてありがとう、
アンディ