import	java.net.MalformedURLException;										
import	java.net.URL;										
import	java.util.HashMap;										
import	java.util.ArrayList;										
import	java.awt.BorderLayout;									
import	java.applet.AppletContext;										
import	javax.swing.JApplet;										
import	javax.swing.JLabel;										
import	javax.swing.JList;										
import	javax.swing.JScrollPane;										
import	javax.swing.event.ListSelectionEvent;										
import	javax.swing.event.ListSelectionListener;										
import java.io.*;
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
import java.awt.geom.*;
											
public	class	SiteSelector	extends	JApplet	implements ListSelectionListener 						
{											
private	HashMap<Object,	URL	>	sites;	//	site	names	and	URLs	
private	ArrayList<	String	>	siteNames;	//	site	names				
private	JList	siteChooser;	//	list	of	sites	to	choose	from		
private String name[]={"Turhan Coban",
                           "Java home",
                           "Ege University",
                           "E.U. School of Engineering, Mechanical engineering dept."};
private String adress[]={"http://www.turhancoban.com/",
                             "http://java.sun.com/",
                             "http://www.ege.edu.tr/",
                             "http://me.ege.edu.tr/"};                          
                          
public void init() 
{  
//	create	GUI	components	and	layout	interface				
add(	new	JLabel(	"Choose a site to browse"	),	BorderLayout.NORTH	);
siteChooser	=	new	JList(name);
siteChooser.setVisibleRowCount(5);	
siteChooser.addListSelectionListener(this);
add(new	JScrollPane(siteChooser	),	BorderLayout.CENTER	);
}

public	void	valueChanged(	ListSelectionEvent	event	)						
{
//	use	site	name	to	locate	corresponding	URL
String site=adress[siteChooser.getSelectedIndex()];
try{
URL newDocument	=	new URL(site);
System.out.println("www="+newDocument.toString());
AppletContext	browser	=	getAppletContext();				
browser.showDocument(newDocument);
  }catch ( MalformedURLException urlException )
{urlException.printStackTrace();} // end catch
									
}	//	end	method	valueChanged							

}	//	end	class	SiteSelector							
