gujuraja143
asked on
Loading HTML
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yes JEditorPane can be used, but it is pretty limited in it's HTML support.
... or if this is not enough you could use JavaHelp.
* Created on Mar 25, 2003
*
* To change this generated comment go to
* Window>Preferences>Java>Co
*/
package tests.swing.text;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent
import java.awt.event.ActionListe
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
f.setSize(100, 80);
f.setLocation(50, 100);
f.getContentPane().setLayo
JButton help = new JButton("Help");
help.addActionListener(new
public void actionPerformed(ActionEven
JFrame helpFrame = new JFrame();
helpFrame.getContentPane()
JEditorPane browser = new JEditorPane();
browser.setEditable(false)
try {
browser.setPage("https://www.experts-exchange.com");
} catch (Exception ex) {
ex.printStackTrace();
}
helpFrame.getContentPane()
helpFrame.setSize(500, 500);
helpFrame.setLocation(160,
helpFrame.setVisible(true)
}
});
f.getContentPane().add(hel
f.setVisible(true);
}
}