File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Swings & HTML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Swings & HTML" Watch "Swings & HTML" New topic
Author

Swings & HTML

vandana
Greenhorn

Joined: Mar 29, 2001
Posts: 13
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

Joined: Apr 26, 2001
Posts: 29
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

Joined: Jul 08, 2001
Posts: 9

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

Joined: Jul 08, 2001
Posts: 9
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

Joined: Jan 07, 1999
Posts: 6920
"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.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
 
wood burning stoves
 
subject: Swings & HTML
 
Similar Threads
Swings + Event handeling
usebean tag gives problems while instantiating bean
Swings+HTML
swings
Swings+HTML