?
Solved

Loading HTML

Posted on 2003-03-24
4
Medium Priority
?
272 Views
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.
0
Comment
Question by:gujuraja143
[X]
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
4 Comments
 
LVL 92

Accepted Solution

by:
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:
http://www.javaworld.com/javaworld/javatips/jw-javatip66.html 

0
 
LVL 9

Expert Comment

by:Ovi
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.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          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();
                    browser.setEditable(false);
                    try {
                         browser.setPage("http://www.experts-exchange.com");
                    } catch (Exception ex) {
                         ex.printStackTrace();
                    }
                    helpFrame.getContentPane().add(new JScrollPane(browser), BorderLayout.CENTER);
                    helpFrame.setSize(500, 500);
                    helpFrame.setLocation(160, 100);
                    helpFrame.setVisible(true);
               }
          });

          f.getContentPane().add(help, BorderLayout.CENTER);
          f.setVisible(true);
     }
}
0
 
LVL 92

Expert Comment

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

Expert Comment

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

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