Hi,
I am having trouble writing a program that can display html files, and allow the user to use scrollbars to view the entire document. The characters appear blurred and distorted whenever I use the scrollbars. The original html area that can be viewed is cleared, until the scrollbars are used.
My code is :
JEditorPane editorPane = createEditorPane();
JScrollPane editorScrollPane = new JScrollPane(editorPane);
editorScrollPane.setVerticalScrollBarPolicy(
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
editorScrollPane.setPreferredSize(new Dimension(250, 145));
editorScrollPane.setMinimumSize(new Dimension(10, 10));
c.add(editorScrollPane,BorderLayout.CENTER);
setSize(400,400);
setVisible(true);
show();
}
private JEditorPane createEditorPane() {
JEditorPane editorPane = new JEditorPane();
editorPane.setEditable(false);
String s = null;
try {
s = "file:"
+ System.getProperty("user.dir"
+ System.getProperty("file.separator"
+ "mymoose.html";
URL helpURL = new URL(s);
displayURL(helpURL, editorPane);
} catch (Exception e) {
System.err.println("Couldn't create help URL: " + s);
}
return editorPane;
}
private void displayURL(URL url, JEditorPane editorPane) {
try {
editorPane.setPage(url);
} catch (IOException e) {
System.err.println("Attempted to read a bad URL: " + url);
}
}
}
If anybody knows a way to display html documents clearly, please let me know.
I am having trouble writing a program that can display html files, and allow the user to use scrollbars to view the entire document. The characters appear blurred and distorted whenever I use the scrollbars. The original html area that can be viewed is cleared, until the scrollbars are used.
My code is :
JEditorPane editorPane = createEditorPane();
JScrollPane editorScrollPane = new JScrollPane(editorPane);
editorScrollPane.setVerticalScrollBarPolicy(
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
editorScrollPane.setPreferredSize(new Dimension(250, 145));
editorScrollPane.setMinimumSize(new Dimension(10, 10));
c.add(editorScrollPane,BorderLayout.CENTER);
setSize(400,400);
setVisible(true);
show();
}
private JEditorPane createEditorPane() {
JEditorPane editorPane = new JEditorPane();
editorPane.setEditable(false);
String s = null;
try {
s = "file:"
+ System.getProperty("user.dir"
+ System.getProperty("file.separator"
+ "mymoose.html";
URL helpURL = new URL(s);
displayURL(helpURL, editorPane);
} catch (Exception e) {
System.err.println("Couldn't create help URL: " + s);
}
return editorPane;
}
private void displayURL(URL url, JEditorPane editorPane) {
try {
editorPane.setPage(url);
} catch (IOException e) {
System.err.println("Attempted to read a bad URL: " + url);
}
}
}
If anybody knows a way to display html documents clearly, please let me know.