TODAY JAVA SCHOOL

In java school, programming, design, computer general knowledge, web application, software, web services, social media, digital marketing, oops, concept of programming language, oops feature, console media, graphics medium, first programming, c, c ++ , Java, PHP, SQL, MySQL, HTML, HTML_5, J_query, JavaScript, Bootstrap, Framework, images with logos, examples, shared and explained.

https://www.amazon.in/b?node=26373545031&linkCode=ll2&tag=1234567801cdb-21&linkId=3b9882431b00409b44141e0344b35a15&language=en_IN&ref_=as_li_ss_tl

Breaking

Monday, 13 April 2020

Applet Communication | Applet To Applet Communication In Java | Applet To Servlet Communication

Applet Communication

java.applet.AppletContext class provides the facility of communication between applets. We provide the name of applet through the HTML file. It provides getApplet() method that returns the object of Applet.



applet to servlet communication


Fig: Applet Communication

Syntax:

            public Applet getApplet(String name){}  


Example of Applet Communication

     
     import java.applet.*;  
     import java.awt.*;   
     import java.awt.event.*;  
    public class ContextApplet extends Applet implements ActionListener{  
    Button b;        
    public void init(){  
    b=new Button("Click");  
    b.setBounds(50,50,60,50);  
    add(b);  
    b.addActionListener(this);  
}  public void actionPerformed(ActionEvent e){  
   AppletContext ctx=getAppletContext();  
    Applet a=ctx.getApplet("app2");  
    a.setBackground(Color.yellow);  
     }  
     }  

myapplet.html

    <html>  
    <body>  
 <applet code="ContextApplet.class" width="150" height="150" name="app">
    </applet>  
  <applet code="First.class" width="150" height="150" name="app2">  
   </applet>  
   </body>  
   </html>  

No comments:

Post a Comment