aspose file tools*
The moose likes Java in General and the fly likes opening  new browser window from applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "opening  new browser window from applet" Watch "opening  new browser window from applet" New topic
Author

opening new browser window from applet

Donny Frank-Rice
Greenhorn

Joined: Dec 30, 2003
Posts: 14
I am working on an applet that contains an Internet usage policy for our library patrons to view and "accept" (by clicking on the acceptance button). I have the applet working so that when a patron chooses to browse the Internet from our menu the applet appears. When the patron clicks on the acceptance button, the browser loads Google in the same page. That works for us. Is it possible to have the applet launch in a browser window that does not have an address bar or navigation buttons? If so, I would need help with rewriting the actionPerformed method so that when the patron clicks on the acceptance button that window closes and a new browser window opens.
I hope I am being clear enough. Any help would be greatly appreciated. Thanks in advance. Here is my actionPerformed method:
//This method opens Google when the acceptance button is clicked
public void actionPerformed(ActionEvent evt)
{
if (evt.getSource() == jbtAgree)
{
try
{
AppletContext context = getAppletContext();
URL url = new URL("http://www.google.com");
context.showDocument(url);
}
catch(MalformedURLException ex)
{
}
}
}
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

There's a two-argument form of "showDocument()" which takes a frame name in addition to the URL; the document is shown in that frame. If you use a non-existent name, a new window is created. Otherwise, I think there's a special name you can use ("__new" ?) which always opens a new frame, although I forget the specifics; maybe someone else remembers.
As this is not an advanced question, I'm moving this to "Applets" for further follow-ups.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: opening new browser window from applet