public void actionPerformed(ActionEvent e)
{
int clicked = 0;
if(arg == "Enter")
{
clicked++;
}
if (clicked == 0)
{
names[0] = nameField.getText();
numbers[0] = numberField.getText();
}
if( clicked == 1)
{
names[1] = nameField.getText();
numbers[1] = numberField.getText();
}
if(arg == "Print")
{
String name = nameField.getText();
String number = numberField.getText();
JOptionPane.showMessageDialog(null,names[0] + numbers[0] + names[1] + numbers[1] + numbers[2] + names[2],"Info",JOptionPane.INFORMATION_MESSAGE);
}
My program must take multiple names and numbers and be able to enter them into an array. After all of the data is entered, it must be able to be printed. I am having trouble under the Enter method because it continues to reset everytime instead of remaining constant. It only allows me to print the last typed name/number instead of saving all of the content. I am unsure of how to fix this and would be grateful for any suggestions at this point.