Como abrir un html desde java

Laida
16 de Septiembre del 2004
Quiero abrir un html desde java, no al revez, no quiero un Applet.
Mi idea para solucionar el problema fu茅 cargar un html en un JEditorPane, pero ni se como ponerle los scrollbar ya que no cabe en la pantalla toda la informaci贸n, ni se como hacer que lea una imagen en una direccion relativa. Espero qque me ayudeis y me digais alguna manera para poder abrir un html desde java, sino es en el explorador por defecto en alg煤n otro lado como puede ser el JEditorPane, pero que se vea lo mas parecido a un html.

Muchas gracias espero que me podais ayudar.

Darwin
16 de Septiembre del 2004
/*Este es un codigo que estoy utilizando para una tarea de matematicas, ya tiene el scroll, ya te visualiza todo, tiene un peque帽o problema con la ubicacion de las imagenes pero por lo general es muy bueno*/

PERO ME TOCO CAMBIAR, POR QUE NECESITO ABRIR PAGINA AYUDA QUE TIENE UN TREE Y ESTO NO FUNCIONA
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.net.URL;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
/*
* Created on 10/09/2004
*
* To change the template for this generated file go to Window - Preferences -
* Java - Code Generation - Code and Comments
*/
/**
* @author dacabe
*
* To change the template for this generated type comment go to Window -
* Preferences - Java - Code Generation - Code and Comments
*/
public class HtmlPanel extends JFrame{
HtmlPanel() {
// create html area
JEditorPane quotePane = null;
JScrollPane scrollPane = null;
try {
URL url = new URL("http://www.google.com");
quotePane = new JEditorPane(url);
quotePane.setEditable(false);
scrollPane = new JScrollPane(quotePane);
scrollPane.setPreferredSize(new Dimension(300, 175));
System.out.println(quotePane.getText());
} catch (java.io.IOException e) {
scrollPane = new JScrollPane(new JTextArea("Can't find HTML file."));
}

getContentPane().setLayout(new BorderLayout());
getContentPane().add(scrollPane, BorderLayout.CENTER);
show();
}

public static void main( String arg[]){
new HtmlPanel();
}
}

Isma
16 de Septiembre del 2004
A lo mejor no es la soluci贸n que est谩s buscando, pero por si te sirve de alguna ayuda te propongo lo siguiente: Puedes abrir el Internet Explorer (p.e.) y cargar el html en 茅l. Para llamar al navegador desde el c贸digo java tienes que hacer esto:

Runtime runTime=Runtime.getRuntime();
Properties p= System.getProperties();
String rutaActual=p.getProperty("user.dir");
String rutaExplorer="C:/Archivos de programa/Internet Explorer/iexplore.exe ";
String rutaAyuda="/ayuda";
String archivoAyuda="/indexJumafriHelp.html";

try {
runTime.exec(rutaExplorer+rutaActual+rutaAyuda+archivoAyuda);
}
catch (IOException ex) {
JOptionPane.showMessageDialog(null, "No se puede hallar la aplicacion");
}

kamegeist
16 de Septiembre del 2004
Le recomiendo un excelent铆simo libro para eso que pide, y para un mont贸n de cosas mas.
Deitel & Deitel, Java How to Program, 3era Edici贸n.