The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
March 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

How to Access another HTML page from JApplet

Posted by Matt Gerrans on October 26, 2001 at 3:40 PM



try
{
java.applet.AppletContext browser = getAppletContext();
url = new java.net.URL("http://www.cyclethere.com");
browser.showDocument( url, "_self" );
}
catch( java.net.MalformedURLException exception )
{
JOptionPane.showMessageDialog( null, "Bad URL!", "Error",
JOptionPane.ERROR_MESSAGE );
}

The second parameter of showDocument() controls whether the URL is displayed in the current browser window, a new named or unnamed one, etc.; see the documentation of AppletContext for different variations. If you want it in the current window, there is also a showDocument() with no second param.

- mfg


> Hi , I am new to this area and trying to work out a SwingApplet
> project. Please let me know how to open a new HTML page in a browser as I clik some button on this SwingApplet which is running in the browser itself.





Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us