How to open any window application with specified size(window) using Java?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vatz
    New Member
    • Mar 2009
    • 4

    How to open any window application with specified size(window) using Java?

    I am using Java to open a window application. i need to open it in a specified size. Please let me know how to do this...Thanks in advance...

    - Vatz
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Which class did you use for the Window? A JFrame? The API specs will contain the methods.

    Comment

    • vatz
      New Member
      • Mar 2009
      • 4

      #3
      Thanks for your reply.
      I am not using JFrame. And i am not developing the application. As part of my work, i just need to open any window application, for eg: windows media player with a predefined size, which i need to specify while opening. Hope you are able to get me.

      - vatz

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        How are you opening the application from Java? Runtime.exec? I suppose it would depend on the application being opened. Whether it allows you to pass window size arguments when launching or whether it allows window resizing at all.

        Comment

        • vatz
          New Member
          • Mar 2009
          • 4

          #5
          Yes. I am using Runtime.exec. Assuming that my application allows to accept window size arguments, could you please tell me how to do that?
          Thanks.

          Comment

          • JosAH
            Recognized Expert MVP
            • Mar 2007
            • 11453

            #6
            Originally posted by vatz
            Yes. I am using Runtime.exec. Assuming that my application allows to accept window size arguments, could you please tell me how to do that?
            Thanks.
            If you can start that other application in the same JVM, i.e. call the main() method of the other's application main class you can get the frame from the Frame class (read the API documentation) and set its size.

            kind regards,

            Jos

            Comment

            • r035198x
              MVP
              • Sep 2006
              • 13225

              #7
              The exact syntax for the arguments would be documented in the application's manual itself. You do know how to call Runtime.exec with a command and arguments right?

              Comment

              • vatz
                New Member
                • Mar 2009
                • 4

                #8
                Thanks to both of you.
                i do know how to call with a command, but i do not know how to use the arguments. please help.

                - Vatz

                Comment

                • JosAH
                  Recognized Expert MVP
                  • Mar 2007
                  • 11453

                  #9
                  Originally posted by vatz
                  Thanks to both of you.
                  i do know how to call with a command, but i do not know how to use the arguments. please help.

                  - Vatz
                  If you take the approach I outlined in my previous reply, you simply do this:

                  Code:
                  public class YourClass {
                     public static void main(String[] myArgs) {
                        final String[] theirArgs= myArgs;
                        try {
                           SwingUtilities.invokeAndWait(new Runnable() {
                              public void run() { OtherApplication.main(theirArgs);
                           });
                           thread.sleep(SOME_TIME); 
                        } catch { e.printStackTrace(); }
                        Frame[] frames= Frame.getFrames();
                        // play with the frames array ...
                     }
                  }
                  kind regards,

                  Jos

                  Comment

                  Working...