Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- This java program copies the value from a jTextField, adds it to a predifined value
- and send it to command-line as a parameter. All these happens if you click the jButton
- */
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- public class ComputerQuery extends JFrame {
- static JTextField jTextField1 = new JTextField(20);
- JButton jButton1 = new JButton("Click");
- static JLabel jLabel1 = new JLabel();
- public ComputerQuery() {
- super("CmdJavaParameterPass");
- getContentPane().setLayout(new FlowLayout());
- getContentPane().add(jTextField1);
- getContentPane().add(jButton1);
- getContentPane().add(jLabel1);
- jButton1.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- sendParam();
- }
- });
- setSize(300, 170);
- setVisible(true);
- }
- public static void sendParam() {
- try {
- String val = MISControlPanel.textField.getText(); // Put whatever
- // you want to
- // pass as a
- // prefix in
- // place of
- // "Computer"
- jLabel1.setText(val);
- Process p;
- p = Runtime.getRuntime().exec(
- "cmd /c start c:\\computerQuery.bat " + val + "");
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- public static void main(String argv[]) {
- new ComputerQuery();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement