public class Chap extends Frame implements ActionListener
{
private Button keys[];
private Panel keypad;
private Panel fields;
private TextField nameField;
private TextField numberField;
private String name;
private int number;
private boolean clearText;
private boolean foundKey;
Button enterButton = new Button("Enter");
Button clearButton = new Button("Clear");
Button printButton = new Button("Print");
String names, numbers;
String ArrayValues[][] = new String[10][2];
public Chap()
{
enterButton.addActionListener(this);
clearButton.addActionListener(this);
printButton.addActionListener(this);
enterButton.setActionCommand("Enter");
clearButton.setActionCommand("Clear");
printButton.setActionCommand("Print");
// construct components and initialize beginning values
nameField = new TextField(20);
numberField = new TextField(20);
nameField.setEditable(true);
numberField.setEditable(false);
keypad = new Panel();
fields = new Panel();
keys = new Button[10];
number = 0;
name = "";
clearText = true;
fields.add(nameField);
fields.add(numberField);
fields.add(enterButton);
fields.add(clearButton);
fields.add(printButton);
public void actionPerformed(ActionEvent e)
{
if(arg == "About")
{
String message = "Program";
JOptionPane.showMessageDialog(null,message,"About Program",JOptionPane.INFORMATION_MESSAGE);
}
if(arg == "Enter")
{
for (int counter = 0; counter < 10; counter ++)
{
}
}
if(arg == "Print")
{
JOptionPane.showMessageDialog(null,ArrayValues,"Info",JOptionPane.INFORMATION_MESSAGE);
}
i have to create a program that store up to 10 phone numbers and names. once the user clicks print, all of the stored data should be displayed. i'm unsure of how to store the data in the array. the name field is editable, while the number field is only able to accessed through the numeric keypad