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

Saturday, 11 April 2020

Painting In Applet

                                     Painting in Applet

We can perform painting operation in applet by the mouse Dragged() method of MouseMotionListener.

Paint use mouse pint brush In applet
Fig: Painting In Applet

Example of Painting in Applet:

    import java.awt.*;   
    import java.awt.event.*;  
    import java.applet.*;  
  public class MouseDrag extends Applet implements MouseMotionListener         {  
    public void init(){  
    addMouseMotionListener(this);   
    setBackground(Color.red);  
    }   
    public void mouseDragged(MouseEvent me){  
    Graphics g=getGraphics();  
    g.setColor(Color.white);  
    g.fillOval(me.getX(),me.getY(),5,5);  
     }   
   public void mouseMoved(MouseEvent me){}  
    
}  
myapplet.html

      <html>  
      <body>  
      <applet code="MouseDrag.class" width="300" height="300">  
      </applet>  
      </body>  
      </html>  

No comments:

Post a Comment