Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

launching a batch file  RSS feed

 
Cyril Martin
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

By using Netbeans & Swing, I managed to create a window that contains:
-2 uneditable combo boxes
-1 ok button

By clicking on the OK button I would like to be able to :
-close the window
-immediately launch a batch file
-pass the 2 combo boxes' parameters to the batch file

I had never used either Netbeans or Swing. However, I have already developped in Java.

Thanks
 
K. Tsang
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Let's break down the problem. Do you know how to "call external programs from Java" (enabling you to call those batch)?

I suspect you used the Netbean's GUI designer to generate Swing code. I highly recommend you code your code GUI code.

For Swing, have you gone over the Swing tutorial here? Have a look at action listeners for the OK button.
 
Cyril Martin
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After having searched on the net I found this:
Runtime.getRuntime().exec("cmd /c start ...");
where ... is the path to the file to be executed. I tried it and it works. However, I still do not know how to transfer data from a Swing application to a job in Talend. I made changes in the context that were unfortunately fruitless.

Thank you for your reply
 
K. Tsang
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For Swing combo box, you can check out the tutorials I referred earlier. Just make sure the combo box is "accessible" for the action listener to retrieve the values.
 
Cyril Martin
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is I'm trying to transfer data from Swing to Talend, not the other way around. I might be mistaken, but I don't think I need action listeners. However, thanks for the reply.
 
K. Tsang
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cyril Martin wrote:The problem is I'm trying to transfer data from Swing to Talend, not the other way around. I might be mistaken, but I don't think I need action listeners. However, thanks for the reply.


Ah Don't get me wrong, you are trying to transfer data "from Swing to Talend" (Talend the open source ETL/big data thing). Given you have a button, when you click it, the window closes and get combo box value and submit batch to Talend. Then action listeners are the way to go.

Imagine if action listeners are not used, how are you trigger the batch submission? If there are no listeners attached to the button or there is one but do nothing, then why do you need a button in the first place?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!