What does the following code do?
package shop.ui;
import javax.swing.JOptionPane;
//import java.io.IOException;
final class PopupUI implements UI {
PopupUI() {}
public void displayMessage(String message) {
JOptionPane.showMessageDialog(null,message);
}
public void displayError(String message) {
JOptionPane.showMessageDialog(null,message,"Error",JOptionPane.ERROR_MESSAGE);
}
public void processMenu(UIMenu menu) {
StringBuffer b = new StringBuffer();
b.append(menu.getHeading());
b.append("\\");
b.append("Enter choice by number:");
b.append("\\");
for (int i = 1; i < menu.size(); i++) {
b.append(" " + i + ". " + menu.getPrompt(i));
b.append("\\");
}
String response = JOptionPane.showInputDialog(b.toString());
int selection;
try (selection >= menu.size()))
selection = 0;
catch (NumberFormatException e) {
selection = 0;
}
menu.runAction(selection);
}
public String[] processForm(UIForm form) {
// TODO
String[]formArray = new String[form.size()];
for(int i=0;i {
String message = JOptionPane.showInputDialog(form.getPrompt(i));
formArray[i] = message;
}
return formArray;
}
}