Computer Science 108, Fall 2007, The Fennec Browser

This assignment is done in groups, each group of four is completing both Battleship and this assignment. The groups are listed on the battleship pages.


It is, Sir, as I have said, a small browser. And, yet there there are those who love it!

Paraphrase of Daniel Webster from the US Supreme Court case Trustees of Dartmouth College v. Woodward, 1819.


fennec fox picture The Fennec Fox is the smallest fox. The web browser you create for this project is a small (in terms of code footprint) browser, barely functional, but it will allow you to focus on writing a Java program that does something and help orient you toward good design.

You'll work first on making the browser work according the specifications and requirements below. Then you'll work on making the design better: more extensible, better in terms of "good", better documented, more object-oriented, etc.

The Project

(preliminary: from monolithic code to MVC, based on Explorer.java).

  1. 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(); panel.add(myBackButton); panel.add(myNextButton); then the resulting window looks like this:

    backnext in middle

    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.

    
    
    

  2. 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 the myURLDisplay JTextfield. To load the URL you'll probably need to use the JTextfield.getText() method.

  3. 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:

    bookmark menu

  4. 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 doBack and 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.

  5. 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.

  6. 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 (see 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 parent component.

    An example of the menu in use is shown in the figure below.

    bookmark menu

  7. 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 menu option) 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.