Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Swings & HTML

 
vandana
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi folks,
i am making a Help for my sw. I am using Java script for it. I hv made a GUI for my sw. On this GUi i hv a Help menuitem. this menuitem whn clked shd open a browser in wch i hv my help in document form. there r many hyperlinks wthin my help document.
can any one pl. suggest me tht wthr is it posible for me to invoke a internet browser kind of thing frm action listener of a button.
pl reply at ur earliest....
thanx
 
Ana Mihailescu
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This example is part of an applet. If the "conex" button is pressed, it opens a new browser window, for the given url.
public void actionPerformed(ActionEvent e)
{
String comanda=e.getActionCommand();
if (comanda.equals("conex"))
{
String address=t.getText();
// eg. http://www.altavista.com

try {
URL url = new URL(address);
AppletContext context = getAppletContext();
context.showDocument(url);
} catch(MalformedURLException exc)
{ System.out.println("URL wrong !!!\n"); }
}
}
 
vinod ac
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi try this code !! it works !!!
public void acionPerformed(ActionEvent ae) {
if(ae.getSource()==jb)
{
Runtime r = Runtime.getRuntime();
Process p = null;
try
{
p = r.exec("C:/Program Files/Internet Explorer/iexplore www.eye4u.com");
}
catch(Exception e)
{
System.out.println("Error opening Internet Explorer...");
}
}
}
jb -> Object of class JButton
Runtime & Process are in java.lang Package. So u need not import the java.lang package
 
vinod ac
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi...
I have misspelled actionPerformed as acionperformed
So plz correct it.
Actually u can run any exe file like notepad,mspaint etc... provided u give the correct path.
While giving the path be careful !!!
u must use forward slash(/) and not backward slash(\)
While running the Internet Explorer give the path of iexplore.exe file and pass the path of ur html file as an arguement.
In the code that i have given, internet explorer will open and will start downloading www.eye4u.com. Similarly u give the path of ur html file.
alright ?? clear ??? byeee....
-Vinod
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"vandana",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements.
Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic