import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.*;
@SuppressWarnings("serial")

public class TicTacToe extends JApplet implements MouseListener
{
	public void init ()
	{
		Display display = new Display();
		setContentPane(display);
		
	}
	
	class Display extends JPanel implements MouseListener
	{
		Display()
		{
			setBackground(Color.BLUE);
			addMouseListener(this);
		}
        public void mousePressed(MouseEvent evt)
        {
        	if (evt.isShiftDown())
        	{
        		repaint();
        		return;
        	}
        	int x = evt.getX();
        	int y =evt.getY();
        	
        	Graphics g = getGraphics();
        	Font myFont = new Font("Arial",Font.PLAIN, 20);
    		g.setFont(myFont);
    		
    		//draw rectangle
    		g.drawString("Rectangle",60,80);
    		g.setColor(Color.RED);
    		g.drawRect(55,60,100,40);
    		
    		//draw rectangle
    		g.drawString("Square",190,80);
    		g.setColor(Color.GREEN);
    		g.drawRect(195,60,100,100);
    		
    		
        	if (evt.isMetaDown())
        	{
        		g.setColor(Color.BLUE);
        		g.fillOval(x-30,y-15,60,30);
        		g.setColor(Color.BLACK);
        		g.drawOval(x-30,y-15,60,30);
        		
        	}
        	else
        	{
        		g.setColor(Color.BLUE);
        		g.fillOval(x-30,y-15,60,30);
        		g.setColor(Color.BLACK);
        		g.drawOval(x-30,y-15,60,30);
        		
        	}	
        	g.dispose();
        	
        }// end mousePressed
        public void mouseEntered (MouseEvent evt) {}
        public void mouseExited(MouseEvent evt) {}
        public void mouseClicked (MouseEvent evt) {}
        public void mouseReleased(MouseEvent evt) {}
        
        
        
	}// end of class Display
	@Override
	public void mouseClicked( MouseEvent e)
	{
		System.out.printf("x: %d  y: %d",e.getX(),e.getY());
		Font myFont = new Font("Arial",Font.PLAIN, 30);
		Graphics g = getGraphics();
		g.setFont(myFont);
		g.drawString("Rectangle",60,80);
	}
	@Override
	public void mouseEntered( MouseEvent arg0)
	{
		
	}
	@Override
	public void mousePressed( MouseEvent arg0)
	{
		
	}
	@Override
	public void mouseReleased( MouseEvent arg0)
	{
		
	}
}