Stando Posted April 17, 2022 Posted April 17, 2022 Hello everyone. Stando here. I am looking for someone to assist me/give me a tutorial in allowing user input for a GUI. I would like this GUI to accept any monster id so the user will automatically attack the monster. I know how to do this with JCombobox, but not with JTextField. Would anyone with this sort of knowledge be able to assist me?
Malcolm Posted April 17, 2022 Posted April 17, 2022 https://docs.oracle.com/javase/7/docs/api/javax/swing/JTextField.html
BravoTaco Posted April 17, 2022 Posted April 17, 2022 If you are not needing an entire GUI, you could use the JOptionPane class, it allows you to bring up a modal input dialog box with just one line of code. String monsterID = JOptionPane.showInputDialog("Please enter the monster ID.");
Stando Posted April 17, 2022 Author Posted April 17, 2022 7 hours ago, BravoTaco said: If you are not needing an entire GUI, you could use the JOptionPane class, it allows you to bring up a modal input dialog box with just one line of code. String monsterID = JOptionPane.showInputDialog("Please enter the monster ID."); Wow, this seems like a good idea. I am going to test this line and see how it looks within the GUI.