To create a Java Bean to draw various graphical shapes and display it using
#1

Aim: to create a Java Bean to draw various graphical shapes and display it using or without using BDK
Algorithm:
1. Create a class Appletdemo which extends Applet superclass and which implements ActionListener interface
2. Create five buttons with the required captions and add them to the container
3. Register the buttons with the ActionListener interface
4. In the Actionperformed () method, with the help of the instance, perform the action respectively
5. In the paint() method, check which button is pressed and display the shapes accordingly

Program
Code:
import java.awt.*;
import java.applet.*;
import java.awt.event.*;

//<applet code="Appletdemo" height=500 width=500></applet>

public class Appletdemo extends Applet implements ActionListener
{

    String s;
    Button b1,b2;

    public void init()
    {
        b1= new Button("Test");
        b2=new Button("circle");
        add(b1);
        add(b2);
        b1.addActionListener(this);
        b2.addActionListener(this);
    }

    public void actionPerformed(ActionEvent ae)
    {
        s=ae.getActionCommand();
        repaint();
    }

    public void paint(Graphics g)
    {
        try
        {
        if(s.equals("Test"));
        g.drawOval(122,53,62,75);
        //g.setColor(212, 23,45);

        if(s.equals("circle"));
        g.drawRect(122,122,122,122);

        }
        catch(NullPointerException e)
        {}
    }
}

Sample Output
[attachment=14669]
Reply

Important Note..!

If you are not satisfied with above reply ,..Please

ASK HERE

So that we will collect data for you and will made reply to the request....OR try below "QUICK REPLY" box to add a reply to this page
Popular Searches: signature shapes from image matlab code, bean recipes, create downlode resume bams online, bean soup, create a java bean to draw eclipse square shapes and display it usmg or without using bdk, how to create hospital registration form in android, seminar on various display devices and printers,

[-]
Quick Reply
Message
Type your reply to this message here.

Image Verification
Please enter the text contained within the image into the text box below it. This process is used to prevent automated spam bots.
Image Verification
(case insensitive)

Possibly Related Threads...
Thread Author Replies Views Last Post
  Simple Key Events Java source code smart paper boy 3 3,562 07-02-2017, 03:41 PM
Last Post: NARESHLAFOOT
  CIRCULAR CONVOLUTION OF TWO FINITE LENGTH SEQUENCES USING DFT AND IDFT seminar class 1 9,433 21-11-2012, 12:18 PM
Last Post: seminar details
  Window Events Java source code smart paper boy 1 3,642 02-03-2012, 10:48 AM
Last Post: seminar paper
  Inter net banking java source code smart paper boy 3 5,908 01-03-2012, 11:24 AM
Last Post: seminar paper
  UDP server java source code smart paper boy 1 3,785 05-01-2012, 05:50 PM
Last Post: jeslinapeter
  UDP client Java source code smart paper boy 2 3,642 12-12-2011, 09:56 AM
Last Post: seminar addict
  Text Demo Java source code smart paper boy 0 2,057 30-08-2011, 12:44 PM
Last Post: smart paper boy
  Text Area Demo Java source code smart paper boy 0 2,060 30-08-2011, 12:44 PM
Last Post: smart paper boy
  Servlet Database Java source code smart paper boy 0 2,437 30-08-2011, 12:42 PM
Last Post: smart paper boy
  server test Java source code smart paper boy 0 2,248 30-08-2011, 12:42 PM
Last Post: smart paper boy

Forum Jump: