0
我有一個帶有打開和後退按鈕的窗體。通過打開按鈕打開我的批處理文件,當批處理文件正在執行時,其他按鈕被禁用。我想啓用這些按鈕。請幫幫我。在執行.bat文件時啓用按鈕
運行批處理文件代碼:
private void openActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
// back.setEnabled(true);
String filename = "C:\\JMeter Project\\jakarta-jmeter-2.5.1\\bin\\jmeter.bat";
String command = filename;
Runtime runtime = Runtime.getRuntime();
try {
Process process = runtime.exec(command);
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line = reader.readLine();
while (line != null) {
System.out.println(line);
line = reader.readLine();
System.out.println(line);
}
back.setEnabled(true);
JOptionPane.showMessageDialog(null, "Batch file executed successfully.....!!!!");
} catch (IOException e) {
JOptionPane.showMessageDialog(null, "Batch file execution failed.");
}
// Form f=new Form();
// back.action(f.setVisible(true),null);
}
後退按鈕代碼:
private void backActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
close();
sms_sound s = new sms_sound();
//s.setVisible(true);
Form f = new Form();
f.setVisible(true);
// back.setEnabled(true);
}
我要指出,你的其他問題是回按鈕將只能重新啓用,如果過程沒有失敗......不知道這是否你想要的功能,但它看起來很腥 – MadProgrammer 2013-02-28 06:56:20