Posted By:
Pepe_Pepe
Posted On:
Monday, June 10, 2002 08:29 AM
I want to view a html file in a JEditorPane. I can do it if the file has only one page, but with more pages I can't. How can I do it? private void jbInit() throws Exception { //Creo el panel htmlPane=new JEditorPane(); htmlPane.setEditable(false); //Creo el ScrollPane donde voy a meter el panel JScrollPane editorScrollPane = new JScrollPane(htmlPane); editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); editorScrollPane.setPreferredSize(new Dimension(550, 550)); this.getContentPane().add(editorScrollPane,BorderLayout.CENTER);
More>>
I want to view a html file in a JEditorPane.
I can do it if the file has only one page, but with more pages I can't.
How can I do it?
private void jbInit() throws Exception {
//Creo el panel
htmlPane=new JEditorPane();
htmlPane.setEditable(false);
//Creo el ScrollPane donde voy a meter el panel
JScrollPane editorScrollPane = new JScrollPane(htmlPane);
editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
editorScrollPane.setPreferredSize(new Dimension(550, 550));
this.getContentPane().add(editorScrollPane,BorderLayout.CENTER);
String s = null;
try {
System.out.println("User directory is "
+ System.getProperty("user.dir")
+ System.getProperty("file.separator"));
s = "file:" + "E:/USUARIOS/Beatriz/Base/EjemploRA1ªversion.htm";
if (DEBUG) System.out.println("Help URL is " + s);
helpURL = new URL(s);
displayURL(helpURL);
}
catch (Exception e) {
System.err.println("Couldn't create help URL: " + s);
}
}
private void displayURL(URL url) {
try {
htmlPane.setPage(url);
}
catch (IOException e) {
System.err.println("Attempted to read a bad URL: " + url);
}
}
<<Less