aspose file tools*
The moose likes Applets and the fly likes Launching applet from within another applet? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Launching applet from within another applet?" Watch "Launching applet from within another applet?" New topic
Author

Launching applet from within another applet?

jake lincoln
Greenhorn

Joined: Apr 26, 2014
Posts: 2
I've been wanting to hit a button in my first applet and using actionListener open the 2nd applet, both in the same package in eclipse. How do I go about doing this? Can I have both applets in one together and have one run and the other not run until the button is clicked or something like that. Im new to this






When i hit the button to launch other applet i get null pointer exception:

Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
at Test.actionPerformed(Test.java:126)
at java.awt.Button.processActionEvent(Unknown Source)
at java.awt.Button.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

Hi Jake, welcome to the Ranch!

I think you're getting a null from the getApplet() method because there is no such applet in the applet context (i.e. the browser). Perhaps if you wrote your HTML so that it included that applet as well as the one you have there it might work, but frankly I'm at a loss as to why you would want to do such a thing.
jake lincoln
Greenhorn

Joined: Apr 26, 2014
Posts: 2
Paul Clapham wrote:Hi Jake, welcome to the Ranch!

I think you're getting a null from the getApplet() method because there is no such applet in the applet context (i.e. the browser). Perhaps if you wrote your HTML so that it included that applet as well as the one you have there it might work, but frankly I'm at a loss as to why you would want to do such a thing.



I'm not using html just the eclipse program atm. I guess I figured something like visual basic where you hit a button and a new window can appear with its own layout. Was wondering if applets can do the same. Call another applet to open up. For example I hit Inbox and the inbox applet apears separetly. Maybe im misnderstanding something here.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

Misunderstanding? I don't know... why do you want to use applets in the first place? They are a dying technology, only useful in a very limited set of circumstances. So if you're just starting out in Java then applets aren't the way to go. If you want to experiment with a Java-based GUI application then a plain old Java application written in Swing would be much more practical.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Launching applet from within another applet?