597 Assignment 5: Write a Web Browser
Fall 2007, David Matuszek
JEditorPaneand other powerful Java classes.
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:
javax.swing.JEditorPane class can display plain text, RTF
(Rich Text Format), or simple HTML. It has these constructors:
public JEditorPane(URL initialPage) throws IOException
public JEditorPane(String url) throws IOException
public JEditorPane(String mimeType, String text)
Some methods of
public void setPage(URL page) throws IOException
public void setPage(String url) throws IOException
public void setText(String text)
It is possible to follow a link that is displayed in an HTML
JEditorPanemust not be editable.
JTextFieldfor entering new URLs. Hitting Enter in this field should bring you to the new URL.
Preferencesto 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.