Java program to implement a shape selector from a given set of shapes

Sunday, April 4th, 2010

To implement a shape selector from a given set of shapes

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
 
public class shape extend Applet implements itemListener
{
	Chekbox reet,circle,line;
	ChekboxGroup cbg;
 
	String msg;
	String s1="reet";
	String s2="circle";
	string s3="line";
	publice void init()
	{
		cbg=new checkboxGroup();
 
		rect = new checkbox("reet,cbg,tru);
		circle = new Checkbox("circle",cbg.false);
		line = new Checkbox("line",cbg,false);
 
		add(reet);
		add(circle);
		add(line);
 
		rect.addItemListener(this);
		circle.addItemLisener(this);
		line.addItemListener(this);	
	}
	public void item StateChanged(ItemEvent ie)
	{
		repaint();
	}
	publice void paint(Graphics g)
	{
		msg=cbg.getSlectedCheckbox().getLabel();
		if(masg.compareTo(s1)==0)
		{
			g.drawRect(10,40,40,80);
		}
		else if(msg.compareTo(s2)==0)
		{
			g.drawOvel(10,40,80,80);
		}
		else
		{
			g.drawLine(0,0,100,100);
		}
	}
}
Avatar Image

Author Name :
Ranjith

Total : 2 Comments


2 Responses to Java program to implement a shape selector from a given set of shapes

  1. Profumeria

    Nel caso che il profumo che stai cercando non c’è fra i 1700 prodotti che offriamo su questa pagina web, puoi scriverci al nostro e-mail, comunicandoci il nome del profumo che stai cercando. Ci impegneremo a reperirlo per te nei tempi più brevi possibili, l’unica eccezione sono i profumi di classe inferiore.

  2. build a garden shed

    Often time the garden shed plans are not as involved as the plans for larger sheds.

Leave a Reply

Question and Answer
C/C++ Unix & Linux Wordpress
Source codes
C C++ Java

Free email signup