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.
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
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: 35439
9
posted
0
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
posted
0
yes exactly.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35439
9
posted
0
If you have an instance of a class that extends JFrame you can call its setVisible(true) method to display it.
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.
> 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
posted
0
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
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.