aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JApplet to JApplet Communication Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JApplet to JApplet Communication" Watch "JApplet to JApplet Communication" New topic
Author

JApplet to JApplet Communication

Meet Gaurav
Ranch Hand

Joined: Oct 08, 2008
Posts: 492
Hi

I have a JApplet running in the browser, I have a requirement to call another JApplet while clicking the button on the first JApplet. Please assist me.
Leonardo Carreira
Ranch Hand

Joined: Apr 07, 2009
Posts: 489

are both of them applets run on single computer?..

if not, i suggest you to use RMI..

Sorry, perhaps my english language isn't too good.. Prepare for SCJP 6, Please God help me.. ☼
References : [Java.Boot] [JavaChamp] [JavaPrepare]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42262
    
  64
What do you mean by "call another applet"? Applets are embedded in web pages; do you have two applets on the same page, and want to pass information from one to the other? Or do you want to open a new web page that contains the other applet? TellTheDetails


Ping & DNS - my free Android networking tools app
Meet Gaurav
Ranch Hand

Joined: Oct 08, 2008
Posts: 492
Ulf thanks for the reply. I have a simple JApplet class running in the Browser onClicking the button I need to open another new window with differnt buttons and boxes.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42262
    
  64
So there's really no second applet involved - you want to open a new JFrame; is that correct?
Meet Gaurav
Ranch Hand

Joined: Oct 08, 2008
Posts: 492
yes exactly.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42262
    
  64
If you have an instance of a class that extends JFrame you can call its setVisible(true) method to display it.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19718
    
  20

And just for your information, if you ever need to show a modal dialog:

each (J)Applet is contained in a special Frame subclass (representing the browser window or something like that). You can retrieve that using the following code:
(with "this" being the (J)Applet).


Off topic: Sun really should have made that method generic; instead of it should have been That would have made the cast to Frame obsolete.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> I have a simple JApplet class running in the Browser onClicking the button I need to open another new window with differnt buttons and boxes.

perhaps all you need to do is to setup your JApplet as CardLayout, then clicking the button shows another panel in the same applet.
with the new panel showing, clicking close or cancel etc then shows the original panel.
Meet Gaurav
Ranch Hand

Joined: Oct 08, 2008
Posts: 492
Hi
Thanks for all your replies. I just created another JFrame and by clicking the button on the JApplet I moved the control over to JFrame. Please assist me how can I return back to JApplet
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
Meet Gaurav wrote:Hi
Thanks for all your replies. I just created another JFrame and by clicking the button on the JApplet I moved the control over to JFrame. Please assist me how can I return back to JApplet

Wouldn't you rather use a JDialog here instead of a JFrame as what you are describing sounds like (modal?) dialog behavior. The focus will automatically go back to the applet once the dialog is closed, I believe.
Meet Gaurav
Ranch Hand

Joined: Oct 08, 2008
Posts: 492
Yes, JOptionPane helps me. Thanks

JDialog dialog = optionPane.createDialog(null, "Width 150");
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JApplet to JApplet Communication