Doubt in java programming...?
check these codes..
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class pp extends Applet implements ActionListener
{
TextField t;
Button b;
public void init()
{
setLayout(new FlowLayout());
t= new TextField(40 );
b = new Button("Send");
b.addActionListener(this);
add(t);
add(b);
}
public void actionPerformed(ActionEvent e)
{
String str=t.getText();
dc a2 =(dc)getAppletContext().getApplet("a2");
if ( a2 != null )
{
a2.append(str);
}
else
{
System.out.println("Applet not found?");
}
}
}
and the 2nd applet code goes here...
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
/*<Applet code="dc" height=400 width=400></Applet>*/
public class dc extends Applet
{
TextArea t;
public void init()
{
setLayout(new FlowLayout());
t=new TextArea(40,50);
add(t);
}
public void append(String msg)
{
t.setText(msg);
}
}
here goes the html codes...
<HTML><HEAD></HEAD><BODY>
<APPLET CODE="pp.class"
HEIGHT=400 WIDTH=400>
</APPLET>
<APPLET CODE="dc.class"
HEIGHT=500 WIDTH=500>
</APPLET>
</BODY></HEAD>
Don't know why it doesn't works.Can anyone tell me where i have done mistake here....?