Results 1 to 4 of 4
- 02-21-2009, 01:05 AM #1
Member
- Join Date
- Feb 2009
- Posts
- 3
- Rep Power
- 0
How to stop/pause running third party exe?
I do need help as how do you actually stop the running application (same third party exe; that is executed earlier in the program.).. without stopping the whole GUI.
the problem am having is that when application is running.. non of the buttons respond on the GUI. My code is as below:
When I execute, the whole GUI becomes irresponsive untill the application stops by it self.Java Code:try { Runtime rt = Runtime.getRuntime(); File file = fc.getSelectedFile(); //defined earlier in code. result = file.getPath(); //defined earlier in code. String command = "cmd /c clic c:\\mp3play.gd -i " + result; Process pr = rt.exec(command); BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream())); String line=null; while((line=input.readLine()) != null) { System.out.println(line); } int exitVal = pr.waitFor(); System.out.println("Exited with error code "+exitVal); } catch(Exception e) { System.out.println(e.toString()); e.printStackTrace(); }
Thanks in advance!!
- 02-21-2009, 03:58 AM #2
You're going to need to use some kind of threading here. Pay special attention to the tutorial Threading in Swing
- 02-26-2009, 05:57 AM #3
Member
- Join Date
- Jun 2008
- Posts
- 56
- Rep Power
- 0
May be
?Java Code:Process.destroy();
As mentioned above, you need to run another thread with timeout checking code before.Try Controls4J - Advanced Swing Components.
- 02-28-2009, 07:26 AM #4
Senior Member
- Join Date
- Jan 2009
- Posts
- 671
- Rep Power
- 5
Orange Dog is correct. You need multiple threads. On the surface, this sounds easy, but in practice, multi-threaded programming is where the fun (diffculty) and $ is.
A simple approach, which might be sufficient here, would be to have your button press disable the button, spawn a new thread, which then enables that button when the thread completes. something like...
Java Code:button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { button.setEnabled(false); new Thread() { public void run() { ...all your code you were doign here... button.setEnabled(true); } }.start(); } });
Similar Threads
-
Running a third-party-library based application in j2me
By nishantsuneja in forum CDC and Personal ProfileReplies: 0Last Post: 02-08-2009, 09:39 PM -
Cannot Implement Stop And Pause...multiple Actionlisteners..please Help.
By pkumar85 in forum Advanced JavaReplies: 1Last Post: 12-07-2008, 05:50 PM -
pause until JFrame is closed.
By Tamu in forum Advanced JavaReplies: 8Last Post: 11-30-2008, 09:46 PM -
Need to hook up my jsp code to third party vendor
By priya123 in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 08-28-2008, 10:24 PM -
Help with Pause
By trill in forum Java AppletsReplies: 2Last Post: 09-28-2007, 08:50 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks