Assignment # 2
                             Web Browser
                     (Date Assigned: 01/11/08)
                (Due Date: 14/11/08 before class)
InspirationMode of submission will be same as of the first


After the dryness of Assignment 1, I have decided that its time to turn on the ‘hot’ water.
Well, don’t worry; I won’t be giving you to code Windows….well, maybe just a part of
Windows. All of you must be familiar with the famous Internet Explorer. From its inception
in 1995, humanity has become dependant on this little window which itself does seemingly
little. But imagine, if one day, Microsoft deletes all the Internet Explorers from the world
and we are left deprived of its valuable services, what would we do? Well, obviously use
Mozilla FireFox. :P But that still doesn’t stop me from giving you this assignment :P
Hopefully, it will be much more interesting and easier than the last one.

                              Problem Statement

The problem statement is quite simple: You have to implement a Web Browser in your
favorite language, JAVA.. But you won’t have to include all the functions found in a
professional web browser. The requirements list will let you know the features required for
you to include.

But first, what we want you to learn from this assignment:

       1) To get familiar with Java GUI Components like JButton etc.
       2) To get used to event handling.
       3) To refer to the API as much as possible. Please treat it as your guide book. It’s a
          much more valuable resource than you might think.
                  The Graphical User Interface (GUI)

Below you will see a prototype of the web browser we need you to implement. It is NOT
necessary that you follow this exact style or format of the GUI. You may be creative and
place the buttons anywhere you like and may use any color scheme. But all the features
should be present and if your GUI is not intuitive enough then you might lose marks. So,
keep it simple.

You MUST include image icons on the ‘Previous’, ‘Next’, ‘Home’ , ‘History’, ‘Refresh’, and
‘Search’ buttons. Refer to the API to see how JPEGs can be imported onto the button
surface. You may use any appropriate picture you like.

     set pr oxy                       e
                               set hom page                  f ir ewal l
  P evious
   R               N Xt
                    E             O E
                                 H M          ef
                                             R r esh       H TO Y sear ch
                                                            IS R

                                   f avor it es

 addr ess                                                                       GO

              e e y p!
               c t
                o o wa !
              wmmb ge e!
                               Feature List

 (1) Site Panel

This is the place where you will be displaying the web page. I know you must be
wondering how in the world that is going to happen, I will give you a head start. The
Site Panel will be a class that inherits from ‘JEditorPane’ or includes it as a member

 (2) Address Bar

This will simply be a text field where the user can enter his/her desired URL. When
the user presses the ‘Go’ button on the right of the address bar, that particular web
page is to be displayed on the site panel.

 (3) Hyperlinks

Displaying the web page is not enough. One important characteristic of a web
browser is the hyperlink compatibility i.e. when you click on a hyperlink, you are
redirected to the page that the hyperlink was pointing to. Since, JEditorPane does
not accomplish this automatically; you will have to handle these events yourself. But
we’ll give you a hint: look for HyperlinkListener in the API.

 (4) Previous & Next

When a user is surfing the net on your browser, the URLs of each site should be
saved in some data structure. And to aid navigation, the user may select the
‘previous’ button (to go back to the page visited before the current one) and the
‘next’ button (to go onto the page that was visited after the current one). Initially,
both buttons will be disabled. And when the latest accessed page is being shown, the
next button will remain disabled and vice versa. In other words, your browser should
emulate these features available in IE 6.0 or Netscape.
 (5) Home

There will also be a home page to your browser. Whenever your browser loads, your
home page should be displayed. You might want to store your home page URL
somewhere. Plus, you to HAVE to provide an option in the menu bar which allows
the user to specify his desired home page. So, there should be a ‘Set Home Page’
option in your menu bar which, when selected, displays a text field asking for the
new home page. (You may use JOptionPane.showInputDialog(…)).

Make the Home Page URL persistent i.e. you might want to store it in a file. Once a
home page has been set, the browser should display that same page regardless of the
number of times one opens and closes your browser.

 (6) Refresh

This is self-explanatory. The current page should be fetched and displayed again.

 (7) History

When the user selects this option, another form should be displayed. In this form a
list of all the links of the past three days should be shown in the following format:

        www.yahoo.com – 12/09/05, 21:35
        www.hotmail.com – 13/09/05, 20:45 etc.

The History Form should include a Close button that closes the form.

This information of visited web sites may be displayed in containers like a List Box.
However, you are free to choose any container to display the above as long as the
user is able to click on a single item i.e. each item in the list can be clicked. When it is
clicked, that particular web page is to be displayed on the site Panel (but the History
Form should not close).

 (8) Search

There should also be a search facility in your program. When this option is selected,
a JOptionPane (or a custom form) may be displayed to take the search criteria as
input. Once the user submits his query, he should be notified of the number of
matches found in the current open web page. (there is no need to highlight the
specific instances in the HTML document as it is done in professional browsers.)
Just simply display the number of matches found in a dialog box. (You will have to
figure this out yourself.)

 (9) Favorites

This, too, is a very common function and well understood. This option can be
implemented in the Menu Bar or separately as a button. When this option is clicked,
two-sub options should be displayed to the user:

a) Add Favorite: If the user selects this, the user will be prompted to enter the title of
                 the current web page. After taking this input, the site URL and the
                 web page title should be stored ‘persistently’.

b) View Favorite: This will be similar to the history function (will open up a new
                  form) but will not incorporate any date or time in the fields. You
                  may show the titles and their respective URLs in any container you
                  like e.g. JListBox. Remember, if a user clicks on any single item,
                  the web browser should open that particular site.

 (10) Menu Bar
You may use the JMenuBar to make a menu bar or if you want, you can simply
create a series of buttons. But remember, the ‘looks’ of your GUI do count in this

Some functions have already been mentioned above but I’ll list them here again.
IMPORTANT POINT: All the following functions need to be ‘persistent’ in nature
i.e. if I close the browser and open it up again, my settings should not be reset to
default. (Hint: maintain a file)

    a) ‘Set Home Page’ – As explained before, this will prompt the user to enter the
       URL of their desired home page. (You MUST check that the user doesn’t
       enter a blank input)
    b) ‘Firewall’ – The firewall reads a list of key words from an external file. It has
       to check for all these key words in the site address whenever the ‘go’
       button is pressed to execute a site URL in the address bar. If a ‘key word’ is
       found, the site should not open and an appropriate message should be
       displayed to the user (You may display the message on the site panel or even
       in a simple dialog box).

        The ‘Firewall’ selection should prompt the user with two sub-options:
            i. ‘Add/Delete Key Word’
                   1. ADD: the user is prompted to input a key word that is then
                        stored in a file afterwards.
                             2. DELETE: the user is prompted with a list of existing key
                                words. The user selects a ‘keyword’ and that is then deleted
                                from the list.

                      ii. ‘Enable/Disable’ – This simply toggles the Firewall. Implement radio
                          buttons (refer to the API to see what they are) so that the user may
                          select to enable the firewall or disable it. ‘Disabling the firewall’
                          simply means that the site address will no longer be checked for

Thats all for now, folks. Hope you find this assignment interesting. And to avoid last minute
calamities – START EARLY.

All the very best!!

Grading Scheme
               Requirements                                        Percentage
Site Panel & Address Bar                                               10
Previous & Next                                                        10
Refresh & Home                                                          5
Search                                                                 10
History                                                                10
Menu Bar                                                               20
HyperLinks                                                             15
GUI Design                                                             10
Java Docs/Commenting                                                    5
Code Design/ Class usage                                                5

To top