Redirect borwser with JApplet

H

Hannibal

Hi,
I need to find a method to redirect browser to an html page with
JApplet.
Searching the documentation I found showDocument method but this is an
Applet method: how can I use it with a JApplet?
Or does exist another method for redirect?
Thanks
 
A

Andrew Thompson

I need to find a method to redirect browser to an html page with
JApplet.
Searching the documentation I found showDocument method but this is an
Applet method: how can I use it with a JApplet?

Please note there is a better group for those learning Java
<http://www.physci.org/codes/javafaq.jsp#cljh>

The keyword here is 'inheritance'.

If you look at the JavaDocs for JApplet
<http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/JApplet.html>
you will see this near the top of the page..
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Panel
java.applet.Applet
javax.swing.JApplet

This shows that Component extends Object and inherits it's
attributes and methods.

Container extends Component and inherits Component's (and Object's)
methods and attributes.

This continues down through the classes to ensure that JApplet can
call methods of *any* of it's parent classes.
Or does exist another method for redirect?

Well, Applet's 'showDocument' is not really reliable, but..
one problem at a time. ;-)
 
D

Dag Sunde

Well, Applet's 'showDocument' is not really reliable, but..
one problem at a time. ;-)

Can you elaborate a liitle on thisone?

I'm using the showDocument(...) method in a couple of applets
I woldn't like to fail...

TIA...
 
H

Hannibal

Il Sun, 06 Feb 2005 13:12:27 GMT, Andrew Thompson
Please note there is a better group for those learning Java
<http://www.physci.org/codes/javafaq.jsp#cljh>

It's hard for me to find a precise answer to my question in faq...
"how to use inheritance" is not enough ;-)
The keyword here is 'inheritance'.

I know inheritance, but ...
A little piece of code:

public class MyClass extends JApplet implements Runnable
{
/*I need to implement Runnable*/
public void init()
{
/*something*/
}
public void run()
{
/*something else*/
getAppletContext().showDocument("hello.html");
}
}
It doesn't work. How can I do?
Well, Applet's 'showDocument' is not really reliable, but..
one problem at a time. ;-)

I need to use an applet to redirect, in other contests I would be so
happy to use another way... but now I must! ;-)

Thank you for attention,
Bye
 
D

Dag Sunde

/*something else*/
getAppletContext().showDocument("hello.html");
}
}
It doesn't work. How can I do?

this.getAppletContext().showDocument(new URL(getCodeBase().toString() +
"hello.html"), "_self");

....with or without the second "target-frame" parameter have always worked
for me in JApplet based applets...
 
A

Andrew Thompson

Can you elaborate a liitle on thisone?

I'm using the showDocument(...) method in a couple of applets
I woldn't like to fail...

You *need* a back-up strategy.

As soon as I get some time to update my FAQ, I will be flagging
showDocument() [ and showStatus() ] as inherently unreliable, and
only recommended for data the user can do without. :-(
 
A

Andrew Thompson

/*I need to implement Runnable*/

Why? What does it give your end user?

Perhaps you are actually wanting to show a page in a new browser window?
 
H

Hannibal

Il Mon, 07 Feb 2005 08:27:54 GMT, Andrew Thompson
Why? What does it give your end user?

Because redirection isn't the only applet's function.
I need to implement runnable to use threads.
Perhaps you are actually wanting to show a page in a new browser window?

No, I don't need a popup event. I only need that in a particular
condition applet redirects browser to another page.
 
H

Hannibal

this.getAppletContext().showDocument(new URL(getCodeBase().toString() +
"hello.html"), "_self");

...with or without the second "target-frame" parameter have always worked
for me in JApplet based applets...

Thank you! It works!
 

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

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,084
Latest member
HansGeorgi

Latest Threads

Top