Compsci 108, Fall 2005, ExplorerTools
This is an individual assignment. You'll be modifying
the code in
Browser.java to add
new functionality, and sometimes to change the prototypes of existing
functions to accommodate the changes. You can also
snarf the code from the 108 snarf site:
Later, as part of a group, you'll be adding file-browsing to the code
you write, so that you'll be able to browse the web and your local disk
You must do modifications 1-4 to earn a grade
in the C range (depending on the
quality of your work, C+ is the highest grade you can get doing
only items 1-4).
To earn a B-, B, or B+, you must do two of options 5-7 below. To earn an
A- or A you must do all of them, and to earn an A+ you must do all of
them, and do them well. Of course you can add your own embellishments
for extra credit. Your design should fit an MVC architecture.
When you submit, be sure to include a README with information about how
long you spent on the assignment, names of people you talked to
substantively about it, and your impressions of it.
Additions and Changes
- The Back and Next buttons are very far apart. This is,
arguably, a bad choice from a UI-perspective. If the panel
the buttons are in is replaced by one with the default FlowLayout,
using this code: (see
makeButtons where the code
below replaces the BorderLayout panel at the end of the function).
JPanel panel = new JPanel();
then the resulting window looks like this:
Propose a simple solution to keep the buttons together, but at the left
of the bar rather than in the middle. Implement the solution and test
to make sure your solution works.
- Add a "GO" button to load a URL, that does
the same thing as pressing return in the url/address
textbox does (see the screenshot
below for how the button might appear).
This button provides an alternative
to pressing return, but does the same thing. The new
button should be to the right of
myURLDisplay JTextfield. To load the URL
you'll probably need to use the
- You are to add a new Menu, whose title is Go, which contains
options for next, back, and home (the latter option won't do anything
now, the next and back menu choices should mirror what the buttons do,
so that when the buttons function the menu works). The home menu choice
should call a
doHome method which for now can do nothing,
but eventually will act like a Home button on a browser, taking the user
to a home website. Here's one view of what the menu might look like:
- Create a history for your browser and make the back/next buttons
functional to move through that history. When the buttons function, the
menu items should also function since the code you add should be in the
doNext methods, though you may need
to add some functionality when a page is loaded (e.g., when
showPage is called. Hint: you may need or want to refactor
by adding parameters to existing functions so that the existing methods
"know" when to store current state on the back (or next) lists.
Initially the buttons should be disabled so that the user cannot click
them (see the
setEnabled method in the JButton API). If the
user visits a new URL, by either clicking on a link, entering a new URL,
or using the next/back buttons, then it's possible that the buttons will
change to being enabled (from a disabled state) or vice versa
change from enabled to disabled, e.g., if the last item on the "back
list" is visited and thus removed from the back list.
- Implement the home menu item and add a home button to the right of
the back/next buttons. Add a new menu item named "Bookmarks" which has
an option to set/change the homepage to the currently visited URL. Then,
clicking on the home button or selecting home from the "Go" menu should
result in loading/displaying the home page. Don't worry about saving
this state between runs of the program. The home page for a client will
only be maintained while the program is running. Try to find a Home icon
for the button and add it to the button so the button uses an icon
rather than text.
- Add a choice to the "Bookmark" menu so that the currently visited
URL is added (or removed, use a different
menu option) to a list of favorites that's shown in the "Bookmark" menu
as a sequence of strings selectable from the menu. These "favorites"
should be below a separator in the "Bookmark" menu
JMenuItem.addSeparator) that separates the favorites
from the home and add/delete favorite options. The user should be
allowed to choose the displayed name in the menu-selectable favorites
list, so that ola would
be used for
http://www.cs.duke.edu/~ola, as one example.
You should use
JOptionPane.showInputDialog to get input
from the user via a dialog box (there are many versions of this
method, the two-parameter one is simplest to use, you can use
null or the Browser object
this as the
An example of the menu in use is shown in the figure below.
- Allow the user to have multiple web pages open at the same time in
different tabs. (See the swing component JTabbedPane for help in doing
this). The user should be able to create a new tab (e.g., via a
and then open a
web page in that tab. Each tab should probably have its own
history and the Back and Next buttons should have access to the history of
the current tab.
Owen L. Astrachan
Last modified: Wed Dec 7 09:43:10 EST 2005