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


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

Re: JButton and Execute W

Path csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!news.glorb.com!news-out.readnews.com!transit3.readnews.com!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail
From "Brandon McCombs" <brandon.mccombs@THRWHITE.remove-dii-this>
Subject Re: JButton and Execute W
Message-ID <464d19f9$0$15090$4c368faf@roadrunner.com> (permalink)
X-Comment-To comp.lang.java.gui
Newsgroups comp.lang.java.gui
In-Reply-To <1179422059.871542.165620@q75g2000hsh.googlegroups.com>
References <1179422059.871542.165620@q75g2000hsh.googlegroups.com>
Content-Type text/plain; charset=IBM437
Content-Transfer-Encoding 8bit
X-Gateway time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92]
Lines 33
Date Wed, 27 Apr 2011 15:34:34 GMT
NNTP-Posting-Host 96.60.20.240
X-Complaints-To news@tds.net
X-Trace newsreading01.news.tds.net 1303918474 96.60.20.240 (Wed, 27 Apr 2011 10:34:34 CDT)
NNTP-Posting-Date Wed, 27 Apr 2011 10:34:34 CDT
Organization TDS.net
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.gui:1653

Show key headers only | 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