-
Notifications
You must be signed in to change notification settings - Fork 0
/
CalcGUI.java
51 lines (42 loc) · 1.1 KB
/
CalcGUI.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
50
51
import java.net.URL;
import javafx.fxml.FXMLLoader;
import javafx.fxml.FXML;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.scene.control.*;
import javafx.scene.layout.*;
/**
* A Calculator interface in JavaFX!
*
* @author mik
*/
public class CalcGUI extends Application
{
private CalcEngine calc = new CalcEngine();
@FXML
private TextField display;
@FXML
private void numberClick(ActionEvent event)
{
Button button = (Button) event.getSource();
display.setText(display.getText() + button.getText());
}
@FXML
private void clear(ActionEvent event)
{
display.setText("2222");
}
@Override
public void start(Stage stage) throws Exception
{
URL url = getClass().getResource("calc.fxml");
Pane root = FXMLLoader.load(url);
Scene scene = new Scene (root);
stage.setTitle("JavaFX PPA Calculator");
stage.setScene(scene);
stage.show();
}
}