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

class GuiGetInt
{
  public static int get(String s)
  {
    try
    {
      String s2 = 
        JOptionPane.showInputDialog(s);
      
      int k = Integer.parseInt(s2);
      return k;
    }
    catch (Exception e)
      { return -1; }
  }
}


public class Gui2 extends JFrame
{
  /** Comply with Java. */
  public static final long serialVersionUID = 20383;

  String combstr[] = { "A","B","C" };
  JComboBox comb = new JComboBox(combstr);

  static long combobuglast;
  
  JTextArea area = new JTextArea(20,22);

  BorderLayout lay = new BorderLayout();

  public Gui2()
  {
    super("Gui2");

    comb.addActionListener
    (
      new ActionListener ()
      {
        public void actionPerformed
        (
          ActionEvent e
        )
        {
//long current=e.getWhen();
//JOptionPane.showMessageDialog(null,""+current);
if (e.getWhen() == combobuglast)
  return;
combobuglast = e.getWhen();

          int indx = comb.getSelectedIndex();

          int k = GuiGetInt.get("Enter quantity");
          for (int i=0; i<k; ++i)
            //choice(indx);
            area.append( combstr[indx] + "\n" );
        }
      }
    );

    setLocation(new Point(20,40));
    setSize(400,450);
    setDefaultCloseOperation(
      JFrame.EXIT_ON_CLOSE);

    window2();

    setVisible(true);
  }

  void window2()
  {
    Container c = getContentPane();
/*
    c.setLayout(new BorderLayout(5,5));
    c.add(comb,BorderLayout.WEST);
    c.add(area,BorderLayout.EAST);
*/

    c.setLayout(new GridLayout(2,1));
    c.add(comb);
    c.add(new JScrollPane(area));
  }
  

  public static void main( String args[] )
  {
    new Gui2();
  }

}




