• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JApplet to JApplet Communication

 
Ranch Hand
Posts: 492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 494
Eclipse IDE Postgres Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
are both of them applets run on single computer?..

if not, i suggest you to use RMI..
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes exactly.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, JOptionPane helps me. Thanks

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