Hi
Need a bit of help here please to point me in the right direction.
I have a java class file here which i wish from a menu item to open a web page which contains a help page. - ]
-
} else if (arg.equals(" Help Page")) {
-
} else if (arg.equals("BrowserControl")) {
-
parent.doconnect();
-
Below is the java file that calls the web page this works fine for some reason I can’t call it from the previous java class file
Many thanks for any help
Keith -
import java.io.IOException;
-
/**
-
* A simple, static class to display a URL in the system browser. *
-
* Under Unix, the system browser is hard-coded to be 'netscape'.
-
* Netscape must be in your PATH for this to work. This has been
-
* tested with the following platforms: AIX, HP-UX and Solaris. *
-
* Under Windows, this will bring up the default browser under windows,
-
* usually either Netscape or Microsoft IE. The default browser is
-
* determined by the OS. This has been tested under Windows 95/98/NT. *
-
* Examples:
-
* Note - you must include the url type -- either "http://" or
-
* "file://".
-
*/
-
public class BrowserControl
-
{
-
/**
-
* Display a file in the system browser. If you want to display a
-
* file, you must include the absolute path name.
-
*
-
* @param url the file's url (the url must start with either "http://"
-
or
-
* "file://").
-
*/
-
public static void displayURL(String url)
-
{
-
boolean windows = isWindowsPlatform();
-
String cmd = null;
-
try
-
{
-
if (windows)
-
{
-
// cmd = 'rundll32 url.dll,FileProtocolHandler http://...'
-
cmd = WIN_PATH + " " + WIN_FLAG + " " + url;
-
Process p = Runtime.getRuntime().exec(cmd);
-
}
-
else
-
{
-
// Under Unix, Netscape has to be running for the "-remote"
-
// command to work. So, we try sending the command and
-
// check for an exit value. If the exit command is 0,
-
// it worked, otherwise we need to start the browser.
-
// cmd = 'netscape -remote openURL(http://www.javaworld.com)'
-
cmd = UNIX_PATH + " " + UNIX_FLAG + "(" + url + ")";
-
Process p = Runtime.getRuntime().exec(cmd);
-
try
-
{
-
// wait for exit code -- if it's 0, command worked,
-
// otherwise we need to start the browser up.
-
int exitCode = p.waitFor();
-
if (exitCode != 0)
-
{
-
// Command failed, start up the browser
-
// cmd = 'netscape http://www.javaworld.com'
-
cmd = UNIX_PATH + " " + url;
-
p = Runtime.getRuntime().exec(cmd);
-
}
-
}
-
catch(InterruptedException x)
-
{
-
System.err.println("Error bringing up browser, cmd='" +
-
cmd + "'");
-
System.err.println("Caught: " + x);
-
}
-
}
-
}
-
catch(IOException x)
-
{
-
// couldn't exec browser
-
System.err.println("Could not invoke browser, command=" + cmd);
-
System.err.println("Caught: " + x);
-
}
-
}
-
/**
-
* Try to determine whether this application is running under Windows
-
* or some other platform by examing the "os.name" property.
-
*
-
* @return true if this application is running under a Windows OS
-
*/
-
public static boolean isWindowsPlatform()
-
{
-
String os = System.getProperty("os.name");
-
if ( os != null && os.startsWith(WIN_ID))
-
return true;
-
else
-
return false;
-
}
-
/**
-
* Simple example.
-
*/
-
public static void main(String[] args)
-
{
-
displayURL("http://www.javaworld.com");
-
}
-
// Used to identify the windows platform.
-
private static final String WIN_ID = "Windows";
-
// The default system browser under windows.
-
private static final String WIN_PATH = "rundll32";
-
// The flag to display a url.
-
private static final String WIN_FLAG = "url.dll,FileProtocolHandler";
-
// The default browser under unix.
-
private static final String UNIX_PATH = "netscape";
-
// The flag to display a url.
-
private static final String UNIX_FLAG = "-remote openURL";
-
}
4 1677 pbmods 5,821
Recognized Expert Expert
We'd love to help you, but you've posted this in the JavaScript forum.
I've notified a JavaScript moderator so we can get your post moved to a forum where it will receive more relevant exposure.
Hi
Many thanks sorry I have posted to the wrong forum
Keith
acoder 16,027
Recognized Expert Moderator MVP JosAH 11,448
Recognized Expert MVP
Maybe I totally misunderstood your question but have you ever read about Sun's
Java Help System? Here's the link.
kind regards,
Jos
Sign in to post your reply or Sign up for a free account.
Similar topics
by: D. Alvarado |
last post by:
Hello,
I am trying to open a window containing an image and I would like
the image to be flush against the window -- i.e. have no padding or
border. Can I make this happen with a single call to a...
|
by: yup |
last post by:
I was wondering if you know a way to have, let's say, you
would click on a menu bar item (where something like
file, edit, format, help options are on Microsoft Word)
and instead of opening a...
|
by: Martien van Wanrooij |
last post by:
I have been faced a couple of times with the situation that I wanted to
write a script and was worried about a too frequent opening and closing
mysql connections.
To give some examples:
1)I...
|
by: swapcool |
last post by:
Hi,
I am a page having a menu and a few frames life below.
The links in menu open in F3 frame. I also have back/forward buttons in F1 frame.
________________________
____________F1_________|...
|
by: timhaynes1985 |
last post by:
Hi, I am very new to PHP so please go easy on me.
I have a page with 2 divs next to each other, a menu in the left and
content in the right. Now what I want to know, is it possible to
chenge...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |