Loading HTML

Posted on 2003-03-24
Medium Priority
Last Modified: 2010-03-31
After loading my Java Program, I want to click a button, like my help menu button, and load an HTML document or a browser with some information thats already there, like a help file.

How would I do this?  How would I point my actionlistener to that html page and load that html page, my Program is not an applet, its a Java program.
Question by:gujuraja143
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 92

Accepted Solution

objects earned 1000 total points
ID: 8199249
Your action listener should use Runtime.exec() to launch your browser.

Here's an article describing how to do this:


Expert Comment

ID: 8200858
 * Created on Mar 25, 2003
 * To change this generated comment go to
 * Window>Preferences>Java>Code Generation>Code Template
package tests.swing.text;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JScrollPane;

 * @author ovi
public class URLBrowser {

     public static void main(String[] args) {
          JFrame f = new JFrame();
          f.setSize(100, 80);
          f.setLocation(50, 100);
          f.getContentPane().setLayout(new BorderLayout());

          JButton help = new JButton("Help");
          help.addActionListener(new ActionListener() {
               public void actionPerformed(ActionEvent e) {
                    JFrame helpFrame = new JFrame();
                    helpFrame.getContentPane().setLayout(new BorderLayout());
                    JEditorPane browser = new JEditorPane();
                    try {
                    } catch (Exception ex) {
                    helpFrame.getContentPane().add(new JScrollPane(browser), BorderLayout.CENTER);
                    helpFrame.setSize(500, 500);
                    helpFrame.setLocation(160, 100);

          f.getContentPane().add(help, BorderLayout.CENTER);
LVL 92

Expert Comment

ID: 8200899
Yes JEditorPane can be used, but it is pretty limited in it's HTML support.

Expert Comment

ID: 8201018
... or if this is not enough you could use JavaHelp.

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month12 days, 5 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question