Javaで進行状況のJDialogを実装しようとしています。私はファイルを解析しており、新しいファイルを解析し始めた後にJDialogを更新したい。私の問題は、JDialogがリフレッシュしていないことです。私はそれを塗り直すか、サイズを変更しようとしました。私もラベルを削除して新しいラベルを追加しようとしました。進行状況バーを作成する - JDialogを更新する
ProgressDialogクラス:私はそれを使用する方法
public class ProgressDialog extends javax.swing.JDialog {
private JLabel jLabel1;
public ProgressDialog(Window frame) {
super(frame);
this.setResizable(false);
this.setLocationRelativeTo(frame);
initGUI();
//this.setVisible(true);
}
private void initGUI() {
try {
{
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
getContentPane().setLayout(null);
{
jLabel1 = new JLabel();
getContentPane().add(jLabel1);
jLabel1.setText("In Progress..");
jLabel1.setBounds(12, 12, 215, 52);
jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
}
}
this.setSize(255, 114);
} catch (Exception e) {
e.printStackTrace();
}
}
public void setText(String s){
this.setVisible(true);
jLabel1.setText(s);
this.resize(this.getSize());
this.repaint();
}
}
:
ProgressDialog pd = new ProgressDialog(frame);
for(File file:files){
pd.setText("Parsing " + file + ".");
...
}
リンクありがとう、私はそれを実装し、それは正常に動作します。 –