| CIT
597 Assignment 5: Write a Web Browser Fall 2007, David Matuszek |
JEditorPane and other powerful Java classes.Preferences Write a web browser. It will handle images, hyperlinks, and most text markup.
Your browser will be very limited. It will not handle frames, applets, XML, Flash, etc. But it will have one feature that most browsers do not--it will show you the HTTP "wrapper" as well as the page itself. It should look something like this:
The javax.swing.JEditorPane class can display plain text, RTF
(Rich Text Format), or simple HTML. It has these constructors:
public JEditorPane()
public JEditorPane(URL initialPage) throws IOExceptionpublic JEditorPane(String url) throws IOExceptionpublic JEditorPane(String
mimeType, String text)
"text/html"<html>...</html>Some methods of JEditorPane are:
public void setPage(URL page) throws IOExceptionpublic void setPage(String
url) throws IOExceptionpublic void setText(String text)It is possible to follow a link that is displayed in an HTML JEditorPane:
JEditorPane must not be editable.HyperlinkListener to the JEditorPane.
JEditorPane).JTextField for entering new URLs. Hitting Enter in this field should
bring you to the new URL. java.util.Stack.)Preferences to remember window size, position, and
current URL. When the browser is reopened, it should look just the same as
when last closed (unless the information at the URL has changed, of course).
The history (previous URLs) should not be remembered.Supply good Javadoc documentation for all non-private elements of your program.
The Networking Examples page has all the bits and pieces you need. You are welcome to take whatever code fragments you need, and reassemble them into a program that meets the specifications of this assignment.