AppletContext within ActionListener..Help!!
Hello,
How can I use AppletContext in actionlistener that is being called by an applet in another class. All I need is on click on that applet, I wanted to open a document or an HTML page. I am using this code, Please see below and help me.
import java.awt.*;
import java.awt.event.*;
import java.lang.*;
import java.util.*;
import java.applet.*;
import java.net.*;
public class Chat1 extends Applet
{
Color color1 = Color.white;
public void init()
{
setLayout(new FlowLayout());
Chat2 button1 = new Chat2("Chat"); // this string "Chat" acts as an applet. On click of this string, I wanted to opea a document
add(button1);
setBackground(color1);
ChatActionListener listener = new ChatActionListener();
button1.addActionListener(listener);
}
}
class ChatActionListener implements ActionListener
{
public ChatActionListener(){ }
public void actionPerformed(ActionEvent ae)
{
if(ae.getActionCommand().equalsIgnoreCase("Chat"))
{
System.out.println("Clicked:" +ae.getActionCommand());
try{
//AppletContext ac;
ac = getAppletContext();
//URL url1 = new URL("YellowPages1.html");
//ac.showDocument(url1);
}
catch(Exception e){e.printStackTrace();}
}
}
}
Thanks for any help.
Uma

