import javax.swing.*;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.*;
import java.awt.Color;
import java.awt.Container;
import java.util.*;
public class gChap extends JFrame implements ActionListener {
JPanel myPanel;
Container cp;
JLabel myLabel;
JButton myButton;
JTextField myText[];
String labelArray[];
int noTextBox=0;
public gChap(chappe lclChappe) {
noTextBox=lclChappe.getSize();
myText = new JTextField[noTextBox];
labelArray = new String[noTextBox];
cp = this.getContentPane();
cp.setLayout(new GridLayout(noTextBox+1,1));
Map sysMap = lclChappe.getMap();
Iterator it = sysMap.keySet().iterator();
String curKey="";
String curVal="";
int inx=0;
while ( it.hasNext() ) {
curKey = it.next().toString();
curVal = sysMap.get(curKey).toString();
myPanel = new JPanel();
myPanel.setLayout(new GridLayout(1,2));
myLabel = new JLabel(curKey);
labelArray[inx] = curKey;
myText[inx] = new JTextField();
myText[inx].setText( curVal );
myPanel.add(myLabel);
myPanel.add(myText[inx]);
cp.add(myPanel);
inx++;
}
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 gChap 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( labelArray[inx] + ": " + myText[inx].getText());
}
}
} //End of actionPerformed
public static void main(String args[]) {
chappe myChappe = new chappe();
gChap ll = new gChap(myChappe);
ll.setTitle("EXAMPLE");
ll.setSize(400,600);
ll.setVisible(true);
}
} // End of gChap