Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying HTML documents using JAVA

Status
Not open for further replies.

brinker

Programmer
May 31, 2001
48
CA
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'm sorry that i do not know what you are trying to achieve with that block of code, but have you considered using JSP?
 
Hi,

Actually I was trying to display the html document in the JEditorPane. The JEditorPane has scrollbars to view the entire document area. However, when I try to scroll to another point in the JEditorPane, the html area appears to be blurred. I would like the html document to be crisp (ie . like a browser window).

thanks

N.C.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top