import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class FunNameS extends JFrame {

    private JTextField txt;
    private JButton b1;
    private JLabel l1;

    public FunNameS()
    {
	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();
    }
    //this part of the program
    public static void main( String args[] )
    { 
	FunNameS app = new FunNameS();

	app.addWindowListener(
			      new WindowAdapter() {
				      public void windowClosing( WindowEvent e )
				      {
					  System.exit( 0 );
				      } //windowClosing
				  } //WindowAdapter
			      ); // WindowListner
    } //main


}

