Doubt in java programming...?

hello friends,
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.*;
/**/
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...






Don't know why it doesn't works.
Can anyone tell me where i have done mistake here....?

Replies

  • sookie
    sookie
    @mohit Can you please show the error logs ? What error you are getting?
  • Morningdot Hablu
    Morningdot Hablu
    No error sookie...it will compiled fine but communication between applets doesn't take place...check this.....#-Link-Snipped-#
  • sookie
    sookie
    Hi Mohit,

    I checked your code and found that in pp.java at line # 20
    dc a2 =(dc)getAppletContext().getApplet("a2");
    You are trying to call an applet with name as "a2" as per the AppletContext.getApplet method specifications but I checked in your HTML page, there is no name specified. You are supposed to specify the name of the "dc" applet as "a2" in the HTML code. So now your new HTML code should be
    
    
    
    
    
    
    
    Now run, it will work. Let me know if any questions.

    -Sookie

You are reading an archived discussion.

Related Posts

Hello friends, Just logged in to tell you that my PC mouse has been broken. Therefore I am here to get some advice to buy a new wireless mouse. I...
[video=youtube;LG0YzGeAFxk]https://www.youtube.com/watch?v=LG0YzGeAFxk&feature=&p=84B277E20A2617DC&index=0&playnext=1[/video] [video=youtube;0AuMdY3IyJ8]https://www.youtube.com/watch?v=0AuMdY3IyJ8&feature=BF&list=PL84B277E20A2617DC&index=2[/video] [video=youtube;SwOerm8kVfk]https://www.youtube.com/watch?v=SwOerm8kVfk&feature=BF&list=PL84B277E20A2617DC&index=3[/video] [video=youtube;jcoBn_5OxVw]https://www.youtube.com/watch?v=jcoBn_5OxVw&feature=BF&list=PL84B277E20A2617DC&index=4[/video]
hello everybody over there... i want to have some projects ideas of E.C.E. Final year... can anybody help me 4 that.????????? can i do something with networking.. that's Computer networking??????????...
[video=youtube;4TzMyXmzL8M]https://www.youtube.com/watch?v=4TzMyXmzL8M[/video] [video=youtube;TS2odp6rQHU]https://www.youtube.com/watch?v=TS2odp6rQHU&feature=channel[/video] [video=youtube;HbsuwpJgKao]https://www.youtube.com/watch?v=HbsuwpJgKao&feature=channel[/video] [video=youtube;EpzhCP0r11U]https://www.youtube.com/watch?v=EpzhCP0r11U&feature=channel[/video] [video=youtube;R726I9_xuvI]https://www.youtube.com/watch?v=R726I9_xuvI&feature=channel[/video]
Hi all, Recently I am selected at Persistent systems ltd. I want to share a Que which I was asked in HR round. It is like: There are 3 tanks:...