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

public class bille extends JFrame implements ActionListener {

JPanel myPanel;
Container cp;
JLabel myLabel;
JButton myButton;
JTextField myText[];
int noTextBox=0;

public bille(int numItem) {
  myText = new JTextField[numItem];
  noTextBox=numItem;
  cp = this.getContentPane();
  cp.setLayout(new GridLayout(numItem+1,1));

  for(int inx=0; inx < numItem;inx++) {

    myPanel = new JPanel();
    myPanel.setLayout(new GridLayout(1,2));
    myLabel = new JLabel("Label " + inx );
    myText[inx] = new JTextField();
    myText[inx].setText( "value:" + inx );

    myPanel.add(myLabel);
    myPanel.add(myText[inx]);
    cp.add(myPanel);

  }

  myPanel = new JPanel();
  myPanel.setLayout(new GridLayout(1,2));
  myLabel = new JLabel("This is a button --->");
  myButton = new JButton("Process");
  myButton.addActionListener(this);
  myPanel.add(myLabel);
  myPanel.add(myButton);
  cp.add(myPanel);


  this.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } });

} //End of bille constructor

public void actionPerformed(ActionEvent e) {
  if (e.getSource() instanceof JButton) {
    JButton tmpButton = (JButton)e.getSource();
    
    System.out.println("Process Order " + tmpButton.getText());
    for ( int inx=0;inx < noTextBox;inx++) {
      System.out.println("TextBox: " + myText[inx].getText());
    }
  } 
} //End of actionPerformed

public static void main(String args[]) {
  int numItem = Integer.parseInt(args[0]);
  bille ll = new bille(numItem);
  ll.setTitle("EXAMPLE");
  ll.setSize(400,600);
  ll.setVisible(true);

}

} // End of bille