I have a unique problem. I have an application built on swing framework with xml used for design and maven used for build.
I have an applet that is independent of this application. Now i dont have a clue how to embed that applet into a jpanel or into that application. Anything of that will help me immensely. Please suggest if anybody has a clue.
Thanks in advance.
Regards,
Ashish
Regards,
Ashish Nandan
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 25055
posted
0
Can you embed an Applet into a panel? Applets are intended to be top-level containers. Have you tried putting everything in the Applet into a single Component (eg a JPanel which occupies the entire size of the Applet), then put that Component into your Swing GUI?
Campbell Ritchie wrote:Can you embed an Applet into a panel? Applets are intended to be top-level containers. Have you tried putting everything in the Applet into a single Component (eg a JPanel which occupies the entire size of the Applet), then put that Component into your Swing GUI?
Although you are right, you can add an Applet (and JApplet) into a Swing application. After all, Applet (and therefore JApplet) are Containers and Components.
I dont see your exact requirement clearly in your question..
do you want to "embed" it or just invoke it?
In general, if you are willing to get the functionality of this particular applet into your application, I suggest you to invoke the applet through your app.. like import that applet's classes and just create instance and invoke it..
This message was edited 1 time. Last update was at by Shrinath M Aithal
I want to put everything of the applet in a Jpanel and am not getting how to do it. Then I will put it into my GUI. The applet already exists and is independent of the Swing GUI. Any help on this will be highly appreciated.
Hi Shrinath,
Above mentiond is the exact requirement. Kindly go throgh and help if possible.
Shrinath M Aithal
Ranch Hand
Joined: May 20, 2009
Posts: 82
posted
0
Ashish Nandan wrote:Thank you for your replies.
Hi Campbell:
I want to put everything of the applet in a Jpanel and am not getting how to do it. Then I will put it into my GUI. The applet already exists and is independent of the Swing GUI. Any help on this will be highly appreciated.
you want to put everything in applet to a JPanel.. Do you have that applet's source code? if yes, search for the lines where it adds all the components to applet container.. if you've already created a JPanel, start replacing those lines to add to JPanel.. add JPanel to main container.. thats it..
typically, the lines will be like x.add(alabel); etc.. where x is the applet's container and label is a normal label.. so if you want to place the same label into your swing jpanel, create a jpanel with any name, say panel , and replace x.add(alabel) with y.add(alabel);
if the class is extending from applet, then replace it with JFrame.. and add a line to add your jpanel to JFrame, like : this.getContentPane().add(y) where y is your jpanel..
hope that helps..
This message was edited 1 time. Last update was at by Shrinath M Aithal
Ashish Nandan
Greenhorn
Joined: Jun 03, 2009
Posts: 22
posted
0
HI Shrinath,
I just have the applet... no control over it(in form of a jar file). Is there any other way?
Rob Prime wrote:...you can add an Applet (and JApplet) into a Swing application. After all, Applet (and therefore JApplet) are Containers and Components.
I thought I'd quote myself.
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 25055
posted
0
Rob Prime wrote:I thought I'd quote myself.
That saves me the trouble of quoting Rob.
Shrinath M Aithal
Ranch Hand
Joined: May 20, 2009
Posts: 82
posted
0
Rob Prime wrote:...you can add an Applet (and JApplet) into a Swing application. After all, Applet (and therefore JApplet) are Containers and Components..
thats the only way..
or try if you get any "Decompilers" I dont know if it is illegal to reverse engineer a program, but there is a way..
This message was edited 1 time. Last update was at by Shrinath M Aithal
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 25055
posted
0
You may not need to reverse engineer anything. If you unzip the .jar file, you can take all the classes, and add them to the new Panel. You may not get the correct Layout, but it is worth trying.
Rob's method is probably still quicker, however.
Shrinath M Aithal
Ranch Hand
Joined: May 20, 2009
Posts: 82
posted
0
Campbell Ritchie wrote:You may not need to reverse engineer anything. If you unzip the .jar file, you can take all the classes, and add them to the new Panel. You may not get the correct Layout, but it is worth trying.
Rob's method is probably still quicker, however.
but if you reverse engineer with a layout, you'd get to change the layout too.. or just take the components and their actions..
@Ashish Nandan : Dude, please mind this.. if you are stealing something from that applet illegally, please drop the idea.. do it from scratch in your own way.. if you want help in that, dont hesitate to ask.. I dont mean to hurt you, sorry if I did..
This message was edited 1 time. Last update was at by Shrinath M Aithal
Ashish Nandan
Greenhorn
Joined: Jun 03, 2009
Posts: 22
posted
0
Dudes....
Its an official requirement. The applet is already there .... It was used in their previous versions... They have not given us the source code thats it and we have to develop this from scratch.
I had found a way... hope this goes well... need your help in knowing whether the approach is correct. Call that applet in a html file. read that file in editorPane and add that into jpanel.
I had tried this but all its showing a big question mark . Help me out guys please.