This prog is from Java How to prog(Deitel & Deitel-4th Edition).The html codes followed are to display the SiteSelector applet. Why does the applet display in Applet Viewer when I run the html file from there but when I use Internet Explorer or Netscape to display the webpage it won't. Can anyone help me with this. Many thanks in advance
public class SiteSelector extends JApplet { private Hashtable sites; // site names and URLs private Vector siteNames; // site names private JList siteChooser; // list of sites to choose from
// read HTML parameters and set up GUI public void init() { // create Hashtable and Vector sites = new Hashtable(); siteNames = new Vector();
// obtain parameters from HTML document getSitesFromHTMLParameters();
// create GUI components and layout interface Container container = getContentPane(); container.add( new JLabel( "Choose a site to browse" ), BorderLayout.NORTH );
siteChooser = new JList( siteNames );
siteChooser.addListSelectionListener(
new ListSelectionListener() {
// go to site user selected public void valueChanged( ListSelectionEvent event ) { // get selected site name Object object = siteChooser.getSelectedValue();
// use site name to locate corresponding URL URL newDocument = ( URL ) sites.get( object );
// get reference to applet container AppletContext browser = getAppletContext();
container.add( new JScrollPane( siteChooser ), BorderLayout.CENTER );
} // end method init
// obtain parameters from HTML document private void getSitesFromHTMLParameters() { // look for applet parameters in the HTML document // and add sites to Hashtable String title, location; URL url; int counter = 0;
// obtain first site title title = getParameter( "title" + counter );
// loop until no more parameters in HTML document while ( title != null ) {