import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class Rakend extends Applet implements MouseListener{ Button b=new Button("Fill"); Choice c=new Choice(); TextField tf=new TextField(2); Checkbox cb=new Checkbox(); public void init(){ addMouseListener(this); add(c); add(tf); add(cb); c.addItem("circle"); c.addItem("square"); } public void mousePressed(MouseEvent e){ String txt=tf.getText(); int rad=Integer.parseInt(txt); Graphics g=getGraphics(); if(e.getX()<10 && e.getY()<10 && rad==1){ int x1; int x2; int T1; int T2; for(x1=0; x1<51; x1++) for(x2=0; x2<51; x2++){ T1=x1*5; T2=x2*5; g.setColor(new Color( 0, T1, T2 )); g.fillRect( T1, T2, 5, 5 ); } } g.setColor(new Color(e.getX()+e.getY(), e.getX(), e.getY())); String c2=c.getSelectedItem(); if(cb.getState()){ if(c2.equals("circle"))g.drawOval(e.getX()-rad/2, e.getY()-rad/2, rad, rad); if(c2.equals("square"))g.drawRect(e.getX()-rad/2, e.getY()-rad/2, rad, rad); } else{ if(c2.equals("circle"))g.fillOval(e.getX()-rad/2, e.getY()-rad/2, rad, rad); if(c2.equals("square"))g.fillRect(e.getX()-rad/2, e.getY()-rad/2, rad, rad); } } public void mouseReleased(MouseEvent e){} public void mouseExited(MouseEvent e){} public void mouseEntered(MouseEvent e){} public void mouseClicked(MouseEvent e){} }