Results 1 to 6 of 6
  1. #1
    ttelloow is offline Member
    Join Date
    Jul 2010
    Posts
    3
    Rep Power
    0

    Default Running a program in a JPanel

    Background:
    As part of my PhD i am constructing an application for analysing data. The data taken in is parsed into an XML format and stored in a working directory. The analytical tools consist of fairly self contained modules each of which are allotted a tab in a Jtabbedpane. They interact through altering the XMLdata files in the working directory and/or altering a config file.
    Problem:
    The next logical step would seem to be to allow the addition of 'plugins', each provided with a tab of their own (and added as a JPanel) - thus allowing the program to easily updated and modified after i finish my course and move on.
    I cannot find any way of doing this without someone delving into my code, altering it and re-compiling - this seems like a very ugly (& surely unnecessary) solution.
    Question:
    Is it possible to open and run a program inside a JPanel? Does anyone know an example of this being done? If this were possible - then additions to the program could be done by simply altering a config file (to point to and provide the commands for running the program/plugin/new tab in question). It would even be possible (though possibly heretical) for someone to add a tab programmed in another language.

    Any thoughts/ advice regarding this or alternate solutions will be much appreciated.

    Thank you.

    ttelloow

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,776
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by ttelloow View Post
    Background:
    As part of my PhD i am constructing an application for analysing data. The data taken in is parsed into an XML format and stored in a working directory. The analytical tools consist of fairly self contained modules each of which are allotted a tab in a Jtabbedpane. They interact through altering the XMLdata files in the working directory and/or altering a config file.
    Problem:
    The next logical step would seem to be to allow the addition of 'plugins', each provided with a tab of their own (and added as a JPanel) - thus allowing the program to easily updated and modified after i finish my course and move on.
    I cannot find any way of doing this without someone delving into my code, altering it and re-compiling - this seems like a very ugly (& surely unnecessary) solution.
    Question:
    Is it possible to open and run a program inside a JPanel? Does anyone know an example of this being done? If this were possible - then additions to the program could be done by simply altering a config file (to point to and provide the commands for running the program/plugin/new tab in question). It would even be possible (though possibly heretical) for someone to add a tab programmed in another language.
    Are these 'modules' writen by you in Java? i.o.w. are they just classes running in the same application? If so you can define an interface, e.g.:

    Java Code:
    public interface PanelModule {
       public void setPanel(JPanel panel);
       // more methods here?
    }
    ... and make your modules implement this interface; they get a JPanel on startup (the JPanel is connected to a tab in the JTabbedPane). The classes to be loaded can be described in a resource and loaded and instantiated dynamically as a simple form of a 'plugin'.

    kind regards,

    Jos

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,899
    Rep Power
    25

    Default

    Is it possible to open and run a program inside a JPanel?
    That question doesn't make sense. A JPanel is a GUI representation. You draw things there.
    Running a program has nothing to do with drawing a GUI. Its a process involving program instruction steps and a CPU. A program can draw a GUI and it can write to a file and do lots of other things.

    Can you explain your meaning or concept of "running a program"

  4. #4
    ttelloow is offline Member
    Join Date
    Jul 2010
    Posts
    3
    Rep Power
    0

    Default

    I have a feeling that developing a plugin interface using the JPF may be my best bet. I'm relatively new to programming - so forgive me if my understanding of what is and is not practical, is a little skewed:

    Response to Norm's question:

    Quote Originally Posted by Norm View Post
    That question doesn't make sense. A JPanel is a GUI representation. You draw things there.
    Running a program has nothing to do with drawing a GUI. Its a process involving program instruction steps and a CPU. A program can draw a GUI and it can write to a file and do lots of other things.

    Can you explain your meaning or concept of "running a program"
    This is what i had in mind - whether it bares any relation to reality or not.. your guess is better than mine.

    By "inside a JPanel" - i mean the pixels which can be manipulated by a particular instance of JPanel. Which can vary due to resizing, change of tab, movement of scrollbar etc..

    By "running a program" - starting a program (which i'll call "Xprog") & displaying the GUI output which would normally be displayed within a window on the desktop 'inside a JPanel' instead.
    - "Xprog" would need to be informed that the screen size is of the same dimensions as the JPanel upon which it is to be displayed.
    - the GUI output of "Xprog" would need to be re-directed to the coordinates of the JPanel instance.

    - I imagine two possible methods would have to deal with this

    - if full screen
    - else not full screen.
    - The coordinates of the mouse would also need to be converted before being passed on to "Xprog".

    The math behind the conversions would be fairly basic linear algebra. But the underlying code regarding GUI interactions with the desktop environment is way outside of my comfort zone.

    If this has never been done, and there are good reasons why it is not practical to do. I would be interested to learn why, if you could point me in the right direction.

    Thanks

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,899
    Rep Power
    25

    Default

    starting a program (which i'll call "Xprog") & displaying the GUI output inside a JPanel
    Not sure how a java program would capture "GUI output" from another program.
    That's all OS stuff. The OS controls windows.
    This is all a wild idea of how it could be done:
    There would have to be some code to capture all GUI requests from the Xprog and channel them to ???. All the requests for "heavyweight" (ie real OS components) would have to be satisfied by the java program.
    Are there OS interfaces that could intercept those kinds of calls and send them to a java program???

    If the Xprog program were written in Java, then you might be able to intercept the JVM class loads and perhaps insert your code into the path.

  6. #6
    ttelloow is offline Member
    Join Date
    Jul 2010
    Posts
    3
    Rep Power
    0

    Default

    I'll go for the Java Plugin Framework option then,
    Thanks for your help.

Similar Threads

  1. my program is running bit slow!!
    By Arn00p in forum AWT / Swing
    Replies: 18
    Last Post: 05-05-2010, 05:14 PM
  2. Program running indefinitely
    By bayan in forum New To Java
    Replies: 2
    Last Post: 04-27-2010, 10:22 AM
  3. Running a Java Program
    By Valkyrie in forum New To Java
    Replies: 13
    Last Post: 11-05-2009, 04:43 AM
  4. Error running java program using URL
    By gio123bg in forum New To Java
    Replies: 6
    Last Post: 06-30-2009, 07:26 PM
  5. Program using JPanel - problems
    By doozer8688 in forum New To Java
    Replies: 6
    Last Post: 11-05-2008, 12:16 AM

Tags for this Thread

Posting Permissions

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