• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

how can i open new window browser or Internet Explorer from java Applet

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how can i open new window or Explore ... i have made a button at JFrame at the Event of this button it opens the c:/ or others
 
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is the code:
private void loadPage(){
try{
URL url = new URL(getCodeBase()+ "../myPage.jsp");
getAppletContext().showDocument(url,"_new");
}
catch(MalformedURLException me){}
}
Attach Listener to a button and include this function in one of listener's methods.
 
ali rafiq
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have used that class.. its works on "http://" protocol but i like to open "c:/"
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a similar problem, but while I'm not trying to show a local (c url, none of the String parameters of ShowDocument(url,string) enable me to generate a new (2nd) browser window.
I'm running an applet, and have no problem displaying the url, but no matter what variation of
showDocument(url,"_blank/_new/_top/Whatever")
I use, I get the new url displayed in the top frame of my applet, removing the original information. This is NOT what I want.
Here is my button listener:
+++++++++++++++++++++++++++++++++++++++++
void buttonGetUrl_Clicked(Event event)
{
try
{
getUrlName=new URL(textFieldUrl.getText());
getAppletContext().showDocument
(getUrlName, "_new");
}
catch(Exception e)
{
label2.setText("Unable to open Url : "
+textFieldUrl.getText());
label2.setBounds(new Rectangle(9,67,313,15));
label2.setVisible(true);
}
}
++++++++++++++++++++++++++++++++++++
I'd appreciate any ideas. I'm using java 1.3.1 (not fixed in stone, but what's installed on my machine) and attempting to do this without swing, but might change if necessary...
Thanks!
 
Tony Warren
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I discovered that while I WAS using awt.applet (a good thing for IE) the code I had started from used the deprecated handleEvent(event) method. Since my head hurt from beating it against the other problem, I spent a few minutes updating it to use processEvent(AWTEvent) and a standard ActionListener. Afterwards the same code worked just fine, creating a new window for the showDocument(url, "target") method, just like it was supposed to. Who'd a guessed?
Thanks anyone who read & actually thought about my problem. It looks like I got lucky this time...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!