Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

opening new browser window from applet

 
Donny Frank-Rice
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic