dcsimg
Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Client Scripting
Expertise: Beginner
Apr 8, 1997

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


How do I jump to a URL from a window (frame)?

Question:
My problem is that the main applet serves as a sort of navigator page. When the user clicks a certain mouse xy the applet opens a new window (frame). This new frame contains some more graphics and servers as a sub-navigation window. When the user clicks a mouse xy in the window, the applet must make a :

getAppletContext().showDocument(theURL,"_main");, which under normal curcumtances opens a new browser window with the URL. PThe problem is that this seams impossible because I can't even compile the code; I get the message "Can't make static reference to method java.net.URL getDocument." The mouse handler is placed in the main applet and not in the window's class. If I place it in the window's class I get the message "method getDocumentBase() not found in MyFrame" (the name of the window class). Any suggestions?

Answer:
I hope I understand your question. My suggestion is to add a constructor to your frame class that includes an applet parameter:

 class SubNavigator extends Frame {
      private MyApplet master;
      public SubNavigator(MyApplet a, ...) {
         master = a;
         // etc.
      } 
      // etc.
} Using this parameter you may now access the browser context and public members of the applet from inside the frame:
 URL u = new URL(master.getDocumentBase(), "foo.html");
   master.showDocument(u);
   // etc.
DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date