-
Notifications
You must be signed in to change notification settings - Fork 239
/
Copy pathController.java
49 lines (32 loc) · 1.58 KB
/
Controller.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package sample;
import javafx.event.ActionEvent;
import javafx.fxml.Initializable;
import javafx.scene.control.TextField;
import java.net.URL;
import java.util.ResourceBundle;
public class Controller implements Initializable {
public TextField firstNumberTextField,secondNumberTextField,resultTextField;
public void calculateAdd(ActionEvent actionEvent) {
double first = Double.parseDouble(firstNumberTextField.getText());
double second = Double.parseDouble(secondNumberTextField.getText());
resultTextField.setText(String.valueOf(first + second));
}
public void calculateSubtract(ActionEvent actionEvent) {
double first = Double.parseDouble(firstNumberTextField.getText());
double second = Double.parseDouble(secondNumberTextField.getText());
resultTextField.setText(String.valueOf(first - second));
}
public void calculateMultiply(ActionEvent actionEvent) {
double first = Double.parseDouble(firstNumberTextField.getText());
double second = Double.parseDouble(secondNumberTextField.getText());
resultTextField.setText(String.valueOf(first * second));
}
public void calculateDivision(ActionEvent actionEvent) {
double first = Double.parseDouble(firstNumberTextField.getText());
double second = Double.parseDouble(secondNumberTextField.getText());
resultTextField.setText(String.valueOf(first / second));
}
public void initialize(URL url, ResourceBundle rb){
resultTextField.setEditable(false);
}
}