Applet

The applet don’t have any public static void main function.

 

import java.applet.*;

import java.awt.*;

public class as extends Applet

{

public void init()

{

Font f=new Font(“monotype corsiva”,0,43);

setFont(f);

}

public void paint(Graphics g)

{

g.drawLine(12, 12, 140, 180);

g.drawRect(12, 12, 140, 180);

//g.setColor(Color.green);

g.drawOval(12, 12, 140, 180);

//g.setColor(Color.pink);

//g.fillRect(12, 12, 140, 180);

g.drawString(“hello”, 15, 15);

}

}

MOUSE PROGRAMMIN ON APPLET WINDOW

import java.applet.*;

import java.awt.*;

import java.awt.event.*;

public class asi extends Applet implements MouseListener,MouseMotionListener

{              String str=””;

int x,y;

public void init()

{

Font f=new Font(“Monotype corsiva”,0,40);

setFont(f);

addMouseListener(this);

addMouseMotionListener(this);

}

public void paint(Graphics g)

{

g.drawString(str, x, y);

}

@Override

public void mouseClicked(MouseEvent arg0) {

// TODO Auto-generated method stub

str=”mouse clicked”;

repaint();

}

@Override

public void mouseEntered(MouseEvent arg0) {

// TODO Auto-generated method stub

str=”mouse entered”;

repaint();

}

@Override

public void mouseExited(MouseEvent arg0) {

// TODO Auto-generated method stub

str=”mouse exited”;

repaint();

}

@Override

public void mousePressed(MouseEvent arg0) {

// TODO Auto-generated method stub

str=”mouse pressed”;

repaint();

}

@Override

public void mouseReleased(MouseEvent arg0) {

// TODO Auto-generated method stub

str=”mouse released”;

repaint();

}

@Override

public void mouseDragged(MouseEvent arg0) {

// TODO Auto-generated method stub

str=”mouse dragged”;

repaint();

x=arg0.getX();

y=arg0.getY();

}

@Override

public void mouseMoved(MouseEvent arg0) {

// TODO Auto-generated method stub

str=”mouse moved”;

repaint();

x=arg0.getX();

y=arg0.getY();

}

}

Advertisements

Constructive and genuine appreciation and/or criticism most welcome

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s