This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Applets and the fly likes Controling the browser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Controling the browser" Watch "Controling the browser" New topic

Controling the browser

Eoin Mac Aoidh
Ranch Hand

Joined: May 19, 2005
Posts: 48
I am trying to control the left hand side or my browser window ("mainFrame") from the applet I have embeded in the right hand frame. I wrote a simple applet before consisting of just one class and it worked fine using the following code, I had no problems;

However I am now trying to do the same thing, except that I am editing the code of a much more complicated applet. This applet is spread out over about 15 classes and is called in my web page as a .jar file.
The place where I need to use the code above is in one of these classes that the main class calls to deal with mouse movements.
It gives compilation errors -
Seems I cant use the getCodeBase() or getAppletContext().showDocument ... methods - is this because they are not in the main class where the applet is defined and set up? -The class Im trying to use them in dosnt necessarily know that the application is being run as an applet. is this the problem? and is there an obvious way around it?
Im a little out of my depth here.

Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42954
getCodeBase() or getAppletContext()

You're correct that those classes can only be used from the class extending Applet (see here for details). You'll need to get hold of a reference to that class
I agree. Here's the link:
subject: Controling the browser