import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class FunNameJA extends JApplet {

    private JTextField txt;
    private JButton b1;
    private JLabel l1;

    public void init()
    {
	//super( "Funny Name 1.0" );
	
	Container c = getContentPane();
	c.setLayout( new FlowLayout() );

	l1 = new JLabel("Type your name in the box then bonk on the button");
	c.add(l1);
	    
	txt = new JTextField(20);
	c.add(txt);

	b1 = new JButton("I'm done!");
	b1.addActionListener( new ActionListener() 
	    {
		public void actionPerformed ( ActionEvent e )
		{
		    String name = txt.getText();
		    String name2 = new String();

		    for(int i=0; i<name.length(); i++)
			{
			    if ((int)(Math.random()*3) == 2)
				{
				    name2 = name2 + "m";
				}
			    else
				{
				    name2 = name2 + name.charAt(i);
				}
			}
		    String result = name2 + "? You'll have to speak up!"; 
		    JOptionPane.showMessageDialog(new JFrame() , result , "Funny Name" , JOptionPane.INFORMATION_MESSAGE);
		}
	    }
			      );
	c.add(b1);
	
	setSize( 320 , 120 ); // h,v
	//show();
    }

}

