import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class newlift extends Frame
{
        private Label l1,l2;
        private TextField text1,text2;
        int my=0,mx=0,ny=0,nx=0,data1=0,data2=0;

        public newlift()
        {       super("HA HA Oval");
                l1=new Label("X :");
                l2=new Label("Y :");
                text1=new TextField();
                text2=new TextField();
                setLayout(null);
                l1.setBounds(10,40,100,30);
                l2.setBounds(10,80,100,30);
                text1.setBounds(120,40,390,30);
                text2.setBounds(120,80,390,30);
                add(l1);
                add(l2);
                add(text1);
                add(text2);

                addWindowListener(new WindowAdapter(){
                   public void windowClosing(WindowEvent e)
                      {JOptionPane.showMessageDialog(null,"Are you sure to exit !");
                      System.exit(0);
                      }});

               addMouseMotionListener(new MouseMotionAdapter(){
                   public void mouseMoved(MouseEvent m)
                      {int mx=m.getX();
                       int my=m.getY();
                       setCursor(Cursor.getDefaultCursor());
                       if ((mx>=10)&&(mx<=510))
                           {if((my>=120)&&(my<=420))
                              {   setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
                              }
                           }
                      }});

                addMouseListener(new MouseAdapter(){
                   public void mouseClicked(MouseEvent n)
                      {
                       int nx=n.getX();
                       int ny=n.getY();
                       if((nx>=10)&&(nx<=510))
                          {if ((ny>=120)&&(ny<=420))
                             {
                             repaint();
                             }
                          }
                      }});
                }

                public void paint(Graphics g)
                        {g.setColor(Color.pink);
                        g.fill3DRect(10,120,500,300,true);
                         data1=Integer.parseInt(text1.getText());
                         data2=Integer.parseInt(text2.getText());
                         int y=data1*data2;
                         int c=-10;
                         int l=120;
                         if(y>375) {JOptionPane.showMessageDialog(null,"Warning! picture over frame");
                                         text1.setText("");
                                         text2.setText("");
                                       }
                               else {for (int n=1;n<=y;n++)
                                             {
                                                c=c+20;
                                                if(c>500)
                                                  {l=l+20;
                                                  c=10;}
                               g.setColor(new Color(0,c/2,l/2));
                               g.fillOval(c,l,20,20);
                                              }
                                      }
                        }
        public static void main (String arg[])
                {newlift n1=new newlift();
                n1.setSize(520,430);
                n1.setVisible(true);
                n1.setLocation(230,150);

                }
}