Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JApplet to JApplet Communication

 
Meet Gaurav
Ranch Hand
Posts: 492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 489
Eclipse IDE Java Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
are both of them applets run on single computer?..

if not, i suggest you to use RMI..
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
Meet Gaurav
Ranch Hand
Posts: 492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So there's really no second applet involved - you want to open a new JFrame; is that correct?
 
Meet Gaurav
Ranch Hand
Posts: 492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes exactly.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have an instance of a class that extends JFrame you can call its setVisible(true) method to display it.
 
Rob Spoor
Sheriff
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> 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
Posts: 492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, JOptionPane helps me. Thanks

JDialog dialog = optionPane.createDialog(null, "Width 150");
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic