Applet and parent browser

S

simplicity

Folks

Is it possible to get the reference to browser window which contains
the applet?

I tried Window win = (Window)this.getParent() but I do not know what
it really returns.

I tried to verify what the above might be by looking at win.getName().
I am getting "frame0" while the browser window name is
"<document.title> - Windows Internet Explorer".
 
A

Arne Vajhøj

Is it possible to get the reference to browser window which contains
the applet?

I tried Window win = (Window)this.getParent() but I do not know what
it really returns.

I tried to verify what the above might be by looking at win.getName().
I am getting "frame0" while the browser window name is
"<document.title> - Windows Internet Explorer".

Try:

JSObject window = JSObject.getWindow(this);

to get out in the browser and window.gtMember("title") for actually
getting the title.

Untested!

Arne
 
S

simplicity

Try:

JSObject window = JSObject.getWindow(this);

to get out in the browser and window.gtMember("title") for actually
getting the title.

Untested!

Arne

Did not work. According to the documentation JSObject.getMember
returns equivalent to javascript this.name. I tried it and it yields
null.

However, the title is not what I need. As I mentioned in the original
email, I need my applet to obtain the reference to the parent window
(the browser). I need it to feed the specific API which will register
the application with the hardware and allow me to pass the hardware
events to the applet. This API takes the top level window as a
parameter

It is easy for a standalone application - just pass JFrame to API. I
need the equivalent of this when the application runs inside the
browser.
 
S

simplicity

Try:

JSObject window = JSObject.getWindow(this);

to get out in the browser and window.gtMember("title") for actually
getting the title.

Untested!

Arne

Window title is not what I need. I just mentioned it because I thought
that checking it may be used as a form of debugging.

What I need is the reference to parent window (which is a browser) to
be available in the applet the which is running inside it. I need this
to hook up with the hardware which requires the top level window to be
registered.
 
R

Roedy Green

Window title is not what I need. I just mentioned it because I thought
that checking it may be used as a form of debugging.

what you might need is
/**
* find Frame/JFrame enclosing a
Component/Container/Dialog/Applet... Returns null if can't find one.
* Useful when you need to pass the enclosing Frame to to a
JDialog constructor.
*
* @return Frame, will be typically not be a literal Frame, but a
* javax.swing.JFrame, sun.applet.AppletViewer, class
sun.plugin2.main.client.PluginEmbeddedFrame (For JApplet)
*/
public static Frame getParentFrame( Component child )
{
Container c = child.getParent();
while ( c != null )
{
if ( c instanceof Frame )
{
return ( Frame ) c;
}
c = c.getParent();
}
return null;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top