I need to get an integer through a textfield.
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();
}
}
}
this is the code here. so i want to be able to input an integer and then have it set to inputnum. i hope that someone here can help me because this and anot bit is due in about 4 hours
scannerto get input from user. - Sajan Chandran