1
Мне нужно получить целое число через текстовое поле.input integer через текстовое поле
textField_1 = new JTextField();
textField_1.addInputMethodListener(new InputMethodListener() {
public void caretPositionChanged(InputMethodEvent e) {
//protected void processInputMethodEvent(InputMethodEvent e){
//InputMethodListener listener=inputMethodListener;
//op = textField_1.getText();
//inputnum = Integer.parseInt (op);
inputnum = Integer.parseInt(textField_1.getText());
textField.setText (String.format ("%d + %d = ", inputnum));
if(inputnum == numA){
score += 10;
Correctness.setText("That's Correct!");
correct = 1;
}
else{Correctness.setText("That's Incorrect!");
}
}
public void inputMethodTextChanged(InputMethodEvent arg0) {
//inputnum = console.nextInt();
}
}
}
это код здесь. поэтому я хочу иметь возможность вводить целое число, а затем установить его на inputnum. я надеюсь, что кто-то здесь может помочь мне, потому что это и anot бит из-за примерно 4 часа
вы получаете ошибку? – SacJn
используйте 'сканер', чтобы получить вход от пользователя. –
Я не получаю ошибки, я только что отредактировал часть, которую я пробовал. он просто не получает никакого ввода – esmaj