• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Launching applet from within another applet?

 
jake lincoln
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic