PDA

View Full Version : java e html


texerasmo
21-06-2005, 11:18
import java.net.URL;
import javax.swing.JScrollPane;
import javax.swing.JTextPane;

/**
*
* @author erasmo
*/
public class Main {

/** Creates a new instance of Main */
public Main() {
}

/**
* @param args the command line arguments
*/
public static void main(String[] args) {

JTextPane jTxtPane = new JTextPane();
JScrollPane jScrollPane = new JScrollPane();
jScrollPane.getViewport().add(jTxtPane);
try{
URL url = new URL("http://www.ioprogrammo.it");
jTxtPane.setPage(url);

}catch(Exception e){
e.printStackTrace();
}



}

}

non vedo nulla perchè?
dovrei vedere un pagina html in un'applicazione.

Molz
21-06-2005, 11:36
ad occhio penso che tu abbia bisogno di un frame dove inserire i tuoi componenti, senza un frame penso che la JVM non ti butti a video nulla.
Eccoti le modifiche che dovresti fare


import javax.swing.*;

...

public class Main {

...
public static void mian(String args){

...

JFrame jFrame= new JFrame();
jFrame.getContentPane().add(jScrollPane );//aggiungi il componente al frame
jFrame.pack(); //per migliorare la visualizzazione
jFrame.show(); //per visualizzare il frame
}
...

}

texerasmo
21-06-2005, 12:03
ok tnks