473,606 Members | 2,756 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Opening web help page from menu

14 New Member
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.


Expand|Select|Wrap|Line Numbers
  1. ]
  2. } else if (arg.equals(" Help Page")) {
  3.     } else if (arg.equals("BrowserControl")) {
  4.     parent.doconnect();
  5.  


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

Expand|Select|Wrap|Line Numbers
  1. import java.io.IOException;
  2. /**
  3.  * A simple, static class to display a URL in the system browser. *
  4.  * Under Unix, the system browser is hard-coded to be 'netscape'.
  5.  * Netscape must be in your PATH for this to work.  This has been
  6.  * tested with the following platforms: AIX, HP-UX and Solaris. *
  7.  * Under Windows, this will bring up the default browser under windows,
  8.  * usually either Netscape or Microsoft IE.  The default browser is
  9.  * determined by the OS.  This has been tested under Windows 95/98/NT. *
  10.  * Examples:
  11.  * Note - you must include the url type -- either "http://" or
  12.  * "file://".
  13.  */
  14. public class BrowserControl
  15. {
  16.     /**
  17.      * Display a file in the system browser.  If you want to display a
  18.      * file, you must include the absolute path name.
  19.      *
  20.      * @param url the file's url (the url must start with either "http://"
  21. or
  22.      * "file://").
  23.      */
  24.     public static void displayURL(String url)
  25.     {
  26.         boolean windows = isWindowsPlatform();
  27.         String cmd = null;
  28.         try
  29.         {
  30.             if (windows)
  31.             {
  32.                 // cmd = 'rundll32 url.dll,FileProtocolHandler http://...'
  33.                 cmd = WIN_PATH + " " + WIN_FLAG + " " + url;
  34.                 Process p = Runtime.getRuntime().exec(cmd);
  35.             }
  36.             else
  37.             {
  38.                 // Under Unix, Netscape has to be running for the "-remote"
  39.                 // command to work.  So, we try sending the command and
  40.                 // check for an exit value.  If the exit command is 0,
  41.                 // it worked, otherwise we need to start the browser.
  42.                 // cmd = 'netscape -remote openURL(http://www.javaworld.com)'
  43.                 cmd = UNIX_PATH + " " + UNIX_FLAG + "(" + url + ")";
  44.                 Process p = Runtime.getRuntime().exec(cmd);
  45.                 try
  46.                 {
  47.                     // wait for exit code -- if it's 0, command worked,
  48.                     // otherwise we need to start the browser up.
  49.                     int exitCode = p.waitFor();
  50.                     if (exitCode != 0)
  51.                     {
  52.                         // Command failed, start up the browser
  53.                         // cmd = 'netscape http://www.javaworld.com'
  54.                         cmd = UNIX_PATH + " "  + url;
  55.                         p = Runtime.getRuntime().exec(cmd);
  56.                     }
  57.                 }
  58.                 catch(InterruptedException x)
  59.                 {
  60.                     System.err.println("Error bringing up browser, cmd='" +
  61.                                        cmd + "'");
  62.                     System.err.println("Caught: " + x);
  63.                 }
  64.             }
  65.         }
  66.         catch(IOException x)
  67.         {
  68.             // couldn't exec browser
  69.             System.err.println("Could not invoke browser, command=" + cmd);
  70.             System.err.println("Caught: " + x);
  71.         }
  72.     }
  73.     /**
  74.      * Try to determine whether this application is running under Windows
  75.      * or some other platform by examing the "os.name" property.
  76.      *
  77.      * @return true if this application is running under a Windows OS
  78.      */
  79.     public static boolean isWindowsPlatform()
  80.     {
  81.         String os = System.getProperty("os.name");
  82.         if ( os != null && os.startsWith(WIN_ID))
  83.             return true;
  84.         else
  85.             return false;
  86.     }
  87.     /**
  88.      * Simple example.
  89.      */
  90.     public static void main(String[] args)
  91.     {
  92.         displayURL("http://www.javaworld.com");
  93.     }
  94.     // Used to identify the windows platform.
  95.     private static final String WIN_ID = "Windows";
  96.     // The default system browser under windows.
  97.     private static final String WIN_PATH = "rundll32";
  98.     // The flag to display a url.
  99.     private static final String WIN_FLAG = "url.dll,FileProtocolHandler";
  100.     // The default browser under unix.
  101.     private static final String UNIX_PATH = "netscape";
  102.     // The flag to display a url.
  103.     private static final String UNIX_FLAG = "-remote openURL";
  104. }
May 26 '07 #1
4 1687
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.
May 27 '07 #2
Guern1
14 New Member
Hi

Many thanks sorry I have posted to the wrong forum

Keith
May 27 '07 #3
acoder
16,027 Recognized Expert Moderator MVP
Moved to the Java forum.
May 27 '07 #4
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
May 28 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

14
11062
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 window.open function? I would prefer not to create a separate HTML page. So far all I have is the basic var cwin = window.open('images/KJV-THANKS.gif', 'Thanks', 'width=243,height=420,'); cwin.focus();
3
1748
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 dialog box it would "switch" to another page (within the program) and maintain the same menu bar as before. For example, in Quicken I would click on "Finances" then "Account List" and a new page would open under the existing menu bar. It wouldn't...
7
3246
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 am trying to develop a photoalbum (also posted a topic called "array / mysql question"). Of course I can use some wonderful open source albums but at the same time I want to get more familiar with all the ins and outs so my idea is a list of...
7
1928
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_________| | F2 |................................ | | .... |................................ | | M | .............F3...............| | E | ...............................|
28
1861
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 the file being included in the content div when I click on different links in the menu div? So basically, when I click on the 'News' link it includes the file 'news.php' in the content div and so on for the rest of the menu items.
0
7981
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8462
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8127
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8320
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6803
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5994
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3952
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4011
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2458
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 we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.