lectures.htm
 

Assignment 9

Class names: SimpleBrowser
File name: SimpleBrowser.java
Type: Application

Due Date: 7-2-03

Submission Form

Description: In this assignment you will construct one class called "SimpleBrowser". SimpleBrowser is a JFrame and must meet the following requirements:

1) Render HTML Pages - To render HTML, SimpleBrowser will use the HTMLViewer class, "HTMLViewer.java". This class renders the html page, in a JEditorPane. To construct an HTMLViewer, you must pass a reference to your SimpleBrowser class as follows:

HTMLViewer htmlViewer = new HTMLViewer( this );

2) File Menu - Your application must provide a file menu, called "File", with one menu item for exiting the browser, called "Exit". The file menu should look like:

The exit menu item must terminate the program when a user clicks on the "Exit" menu item.

2) About Menu - Your application must provide an help menu, called "Help", with one menu item for displaying information about the program. The help menu must contain one menu item, called "About". The file menu should look like:

The about menu item must display a dialog when the user clicks on the menu item that states "Simple Browser" and your name. For my application it looks as follows:

 

3) URL Label and Text Field - Your program must provide an area for the user to type the url they would like to view. This text field needs to be labeled as "Address:". In addition, your text field must allow the user to type a url and press the enter key, then change the page. To change the page in the HTMLViewer, you need to call the "setWebPage(String url)" method. So you need to listen for the "Enter Key" in the text field and call "setWebPage(String url)". Your program must also check the make sure that the url starts with "http://". If the url the user typed doesn't contain "http://", you must add it to the user's url.

htmlViewer.setWebPage(newURL);

The URL area looks as follows:

4) Status Bar - Your application must have a status bar in the bottom of the application. The status bar does not have any functionality, just presentation appeal. The status bar is created with a JPanel and added to the main application frame.

5) Changing the address - Your application must implement the URLSetable interface. This interface has one method which allows the user to change the text in the address text field. HTMLViewer uses this method when a user clicks a link on a page to display the appropriate web address. You will need URLSetable.java

Here are my JavaDocs for the assignment.

Have Fun!

Objectives:
* Understand Swing GUI components
* Understand BorderLayout Manager

* Understand event handling
* Understand how to implement an interface

 

 

Home | Syllabus | Lectures | Assignments | Schedule | Coding Conventions | Links