So I am trying to make a GUI in Java. I am pretty new to Java GUIs. So here is my code:
private class thehandler implements ActionListener {
public void actionPerformed(ActionEvent event){//this is what is going to handle an event
String string = "";
if(event.getSource() == item1)//if they click enter on item1
string=String.format("field 1: %s", event.getActionCommand());
else if(event.getSource() == item2)//if they click enter on item2
string = String.format("field 2: %s", event.getActionCommand());
else if(event.getSource() == item3)//if they click enter on item3
string = String.format("field 3: %s", event.getActionCommand());
else if(event.getSource() == passField)//if they click enter on passField
string = String.format("Password field is: %s", event.getActionCommand());
}
}
I get an error on string=String.format("field 1: %s", event.getActionCommand()); and all the other String.format lines. It says "The method format(String, Object[]) in the type String is not applicable for the arguments (String, String)"
I have no clue how to fix this. I just downloaded the JRE and JDK 8 if that helps at all. Thank you!