Answer the question
In order to leave comments, you need to log in
Why the program does not want to execute the method called through the keyboard and how to fix it?
There is a method
public void number (String n) {
if (Result.getText().length() < 14) {
wer[0] = wer[0] + n;
Result.setText(wer[0]);
}
}
@FXML
private Text Result = new Text();
numbers entered by the user. btn1.setOnAction(actionEvent -> {
number("1");
});
public void sd(KeyCode q){
switch (q){
case NUMPAD0: number("0"); break;
case NUMPAD1: number("1"); break;
case NUMPAD2: break;
case NUMPAD3: break;
case NUMPAD4: break;
case NUMPAD5: break;
case NUMPAD6: break;
case NUMPAD7: break;
case NUMPAD8: break;
case NUMPAD9: break;
case ADD: plus(); break;
default: System.out.println("NOT FOUND: "+q);;
}
}
case NUMPAD0: number("0"); break;
case NUMPAD0: System.out.println("0"); break;
Answer the question
In order to leave comments, you need to log in
Obviously you have a problem with this method:
public void number (String n) {
if (Result.getText().length() < 14) {
wer[0] = wer[0] + n;
Result.setText(wer[0]);
}
}
number();
if it's non-static. Do you have an instance of a class?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question