user7822324
user7822324

Reputation:

How do you make a program wait for user input?

I'd like to use the variable column_input later.

public static void playGame(){   
    btnNewButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String input = textField.getText();
            chosen_column = Integer.parseInt(input);
            textField.setText(null);
        }
    });
}

Upvotes: 0

Views: 131

Answers (1)

camickr
camickr

Reputation: 324108

Looks like you only need a single piece of data. The easiest solution is to use a JOptionPane. You can prompt for user input.

Read the section from the Swing tutorial on How to Make Dialogs for more information and working examples to get you started.

Upvotes: 1

Related Questions