진행률 JDialog를 Java로 구현하려고합니다. 파일을 파싱하고 새 파일을 구문 분석하기 시작한 후 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 + ".");
...
}
링크를 가져 주셔서 감사합니다. 구현했습니다. 정상적으로 작동합니다. –