Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Open browser when u click a button  RSS feed

 
Flora Ng
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys! Is that possible to implememt a GUI like if u click a button it will get the url, open the browser (netscape or ie) and display the specified website? How can i do that?
Thanks...
 
Luong Nguyen
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Please refer to the following url: http://www.javaranch.com/ubb/Forum2/HTML/002151.html
 
Juanjo Bazan
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Create an instance of Runtime class and invoke exec methods to execute the browser exe. This returns a Process object.
Here is sample code:
public class opening
{
public static void main(String args[])
{
try
{
Runtime rt=Runtime.getRuntime();

Process p=rt.exec("c:\\progra~1\\intern~1\\iexplore.exe","index.html");
}
catch(Exception e)
{System.out.println(e);}
}
}
 
Shane Roylance
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found in my trials to get this to work that you need to have "cmd \C start" in front of your command in order for it to work in a windows environment. For example:
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!