Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #1653

Re: JButton and Execute W

From "Brandon McCombs" <brandon.mccombs@THRWHITE.remove-dii-this>
Subject Re: JButton and Execute W
Message-ID <464d19f9$0$15090$4c368faf@roadrunner.com> (permalink)
Newsgroups comp.lang.java.gui
References <1179422059.871542.165620@q75g2000hsh.googlegroups.com>
Date 2011-04-27 15:34 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.gui
banker123 wrote:
> I am new to Java, I have built a GUI that contains a JButton.  I would
> like this JButton to execute a windows batch file when the user clicks
> the button.  Below is my attempt, please help.
> 
> 
> private void jButton2ActionPerformed(java.awt.event.ActionEvent evt)
> {
> 
>     try {
>     Runtime rt = Runtime.getRuntime();
>     String[] args = {"c:\\test.bat"};
>     Process proc = rt.exec(args);
>     }
>     catch  (IOException e) {
>     System.err.println (e);
>     }
> 
>     }
> 

Maybe you should tell us what the problem is unless you think we can 
read your mind.

At first glance, an ActionListener must implement "public void 
actionPerformed(ActionEvent)" so you need to at least change that in 
your code.

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

Back to comp.lang.java.gui | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

JButton and Execute Windo "banker123" <banker123@THRWHITE.remove-dii-this> - 2011-04-27 15:34 +0000
  Re: JButton and Execute W "Brandon McCombs" <brandon.mccombs@THRWHITE.remove-dii-this> - 2011-04-27 15:34 +0000
    Re: JButton and Execute W "m.djukic" <m.djukic@THRWHITE.remove-dii-this> - 2011-04-27 15:34 +0000

csiph-web