Java Blog

/* <applet code=\"SimpleClick\" height=100 width=400> </applet> */

import java.awt.event.MouseListener;
import java.awt.event.MouseEvent;
import java.applet.Applet;
import java.awt.Graphics;

public class SimpleClick extends Applet implements MouseListener {

    StringBuffer buffer;

    public void init() {
    buffer = new StringBuffer();
        addItem(\"initializing... \");

    public void start() {
        addItem(\"starting... \");

    public void stop() {
        addItem(\"stopping... \");

    public void destroy() {
        addItem(\"preparing for unloading...\");

    void addItem(String newWord) {

    public void paint(Graphics g) {
    //Draw a Rectangle around the applet\'s display area.
        g.drawRect(0, 0, 
           getSize().width - 1,
           getSize().height - 1);

    //Draw the current string inside the rectangle.
        g.drawString(buffer.toString(), 5, 15);

    //The following empty methods can be removed
    //by implementing a MouseAdapter (usually done
    //using an inner class).
    public void mouseEntered(MouseEvent event) {
    public void mouseExited(MouseEvent event) {
    public void mousePressed(MouseEvent event) {
    public void mouseReleased(MouseEvent event) {

    public void mouseClicked(MouseEvent event) {
    addItem(\"click!... \");

    Related Post:
  1. Program that enabled applet calculator

  2. Program to declare and initialize Integer variables and print them on the Standard Output Device

  3. Program to show an example of Driving and using a Class

  4. Write a program for restaurant

  5. Game application in CORBA for which player will guess a number between 1 to 100, which will be compared to the random number generated by the class

  6. Program to show the use of For Loop

  7. Develop a game application in CORBA for which the player will guess a number between 1 to 100, which will be compared to the random number generated b

  8. Program to read the table elements into a two-dimensional array temperature

  9. RMI based application, which reads a file with list of marks of student from a client, send it to server and find how many students having distinct

  10. Write a class whose objects holds a current value and have a method to add that value, printing the new value

  11. Program of bubble sort

  12. Program to show an example of Arrays of String

  13. Program to show an example of Polymorphism

  14. Program in CORBA which takes a long sentence from the client (at least 7 words), passes to the server, server separates out each word

  15. An applet program that creates string dynamically and displays it

  16. Program to show an example of using a recursive method in a class

  17. Program to show the use of Break Statement

  18. Program that enabled applet that takes name of the user. Server returns back the number in uppercase clubbed with “HELLO” and display it on applet

  19. Program to declare, initialize and print a StringBuffer object

  20. An applet program to display barchart of given data

Didn't find what you were looking for? Find more on An applet program showing Clicked Event on canvas