1
我有一個程序,通過我在主函數中調用的函數通過swing獲取用戶的輸入。提交按鈕具有附加的操作執行方法。我試圖在刪除輸入文件並設置文本以通知用戶後重新繪製屏幕。它不會重新繪製,直到try/catch中帶有自定義函數。不知道我在做什麼錯我雖然它會按順序執行?以下是我的行動預先附加到我的提交按鈕。一個注意事項是,如果我做一個frame.dispose()或setVisibility(假)它將刪除框架,任何幫助,將不勝感激。謝謝!!JFrame不會重繪,直到try/catch完成後
button.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
loc = FileLoc.getText();
name = FileName.getText();
//inform user
area.setText("Attempting To Run Test....");
//backGroundPane contains the user input fields and button
frame.remove(backGroundPane);
frame.repaint();
if(loc != null && name != null &&
!loc.equals("") && !name.equals(""))
{
try {
CallDrivers();
} catch (InterruptedException e1) {
System.out.println("Error Running Function");
//e1.printStackTrace();
}
}
else{
area.setText("There are Blank Fields");
System.out.println("test");
}
}});
這似乎只是想我需要謝謝! – Lazadon