I’m trying to use java to create an popup input box with multiple options but I do not know what the easiest way to do this is. Currently when I click on a button in my GUI, this is what it does:
public class LoadListAction implements ActionListener{
public void actionPerformed(ActionEvent e){
Object result = JOptionPane.showInputDialog(f, "Test:");
}
}
however, this only gives me options of ok and cancel. I would like to have a box that popus up and has option 1 and option 2 on it and do different things to whatever is in the input box depending on which button is pressed.
Can anyone help?
EDIT: Ive tried using JDialog but it seems that I can’t get both an input box as well as multiple buttons to click (or at least I don’t know how).
In the JDialog you can use the add() to add as many components you want! As you can see here , you can use many methods that are inherited from
ContainerandComponentinJDialog. yayy!This is a copy-paste snippet from one of my program, hope you can get something from this: