Results 1 to 9 of 9
  1. #1
    ramin1981 is offline Member
    Join Date
    Mar 2012
    Posts
    4
    Rep Power
    0

    Default runing GUI from command

    Hi,
    I have written a code in java which make a frame and on that frame there will few buttons and textboxes. By pressing each button a certain program will be executed and the results will be seen on the textbox. I want to make a wrapper to run this java code from a command line or without calling the graphical output and just 100 times or maybe 1000 times run the code for me and pressing the buttons automatically and store the result without me seeing it or pressing the each button 10000 times.
    I would really appreciate if anyone could help me with this.
    Best wishes
    Ramin

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,862
    Rep Power
    8

    Default Re: runing GUI from command

    Which part of this are you stuck on? What have you tried so far? What is your actual question?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    ramin1981 is offline Member
    Join Date
    Mar 2012
    Posts
    4
    Rep Power
    0

    Default Re: runing GUI from command

    Quote Originally Posted by ramin1981 View Post
    Hi,
    I have written a code in java which make a frame and on that frame there will few buttons and textboxes. By pressing each button a certain program will be executed and the results will be seen on the textbox. I want to make a wrapper to run this java code from a command line or without calling the graphical output and just 100 times or maybe 1000 times run the code for me and pressing the buttons automatically and store the result without me seeing it or pressing the each button 10000 times.
    I would really appreciate if anyone could help me with this.
    Best wishes
    Ramin

    Dear Kevin,
    Thanks for your message. I dont exactly know how to do what I explained. I dont know how to run my program from command and automatically press the buttons number of times without seeing the GUI.

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,862
    Rep Power
    8

    Default Re: runing GUI from command

    Do you have access to the code? If so, you'll have to convert the gui into a command line interface. If not, you can look into using the Robot class to automate things for you, but I predict that's not what you actually want to do.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    ramin1981 is offline Member
    Join Date
    Mar 2012
    Posts
    4
    Rep Power
    0

    Default Re: runing GUI from command

    I do have access to the code, but how can I convert the gui into command line interface? how I can run it 'n' number of times while the buttons are automatically pressed and the results of each text box is saved without calling gui ?

  6. #6
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,862
    Rep Power
    8

    Default Re: runing GUI from command

    You can do this a number of ways. The most logical, to me, is to eliminate the gui and do all input/output/commands from the command line.

    Otherwise, you can simple call things such as button.doClick() to automate the gui.

    Better yet, you could simply write methods that carry out the same commands as pressing a button does.

    Alternatively, you could use the Robot class to fully automate everything.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  7. #7
    ramin1981 is offline Member
    Join Date
    Mar 2012
    Posts
    4
    Rep Power
    0

    Default Re: runing GUI from command

    Thanks for your reply. Let me state my problem once more. I do have a code in Java which opens a GUI for me and on the click on every button it runs a method and outputs the result. I need to automate this process and call the methods of that class "n" times without calling gui each time. So I am going to write another class which accesses the methods of the former class and runs it for me, but I am not sure how I can do that.
    for instance a methods in my class looks like this:
    private JPanel getCSPPanel() {
    JPanel csp_panel = new JPanel();
    csp_panel.setLayout(new BorderLayout());
    JPanel button_panel = new JPanel();
    // I have deleted part of the code, but here generateScenario in the method which does the main job
    generate_scenario_button.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    generateScenario();
    }
    });

    public void generateScenario() {
    try {
    // the code
    }
    }


    so I need to just call this generateScenario method from another class. How do I define this class. I guess just because the first class has a main function, if I define the new class as extended version of former one it creates problem.

    Thanks a lot for your help

  8. #8
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,862
    Rep Power
    8

    Default Re: runing GUI from command

    You would instantiate the existing class just like you instantiate any other Object, then call its methods.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  9. #9
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: runing GUI from command

    Moved from Advanced Java. Whatever led you to believe this to be an 'advanced' question?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Runing .exe from Java
    By Java_B in forum New To Java
    Replies: 8
    Last Post: 11-17-2011, 04:15 PM
  2. School Project - runing out of time D:
    By Bagzli in forum New To Java
    Replies: 3
    Last Post: 03-02-2011, 05:04 PM
  3. error runing a java application
    By samjesse in forum Java Applets
    Replies: 5
    Last Post: 11-05-2009, 03:44 AM
  4. Runing 44 Java Files Easyer
    By crigur in forum New To Java
    Replies: 5
    Last Post: 09-23-2008, 03:35 AM
  5. Trouble in Runing
    By kavithaprabhaker in forum New To Java
    Replies: 5
    Last Post: 05-13-2008, 05:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •