Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. package appcalculator;
  2.  
  3. import javafx.application.Application;
  4. import javafx.fxml.FXMLLoader;
  5. import javafx.scene.Parent;
  6. import javafx.scene.Scene;
  7. import javafx.stage.Stage;
  8.  
  9. public class AppCalculator extends Application {
  10.  
  11. @Override
  12. public void start(Stage stage) throws Exception {
  13. Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));
  14.  
  15. Scene scene = new Scene(root);
  16.  
  17. stage.setScene(scene);
  18. stage.show();
  19. }
  20.  
  21. public static void main(String[] args) {
  22. launch(args);
  23. }
  24.  
  25. }
  26.  
  27. package appcalculadora;
  28.  
  29. import java.net.URL;
  30. import java.util.ResourceBundle;
  31. import javafx.event.ActionEvent;
  32. import javafx.fxml.FXML;
  33. import javafx.fxml.Initializable;
  34. import javafx.scene.control.TextField;
  35.  
  36. public class FXMLDocumentController implements Initializable {
  37.  
  38.  
  39. TextField texto = new TextField();
  40.  
  41.  
  42. @FXML
  43. private void btnOne(ActionEvent event) {
  44. texto.setText("1");
  45.  
  46. }
  47.  
  48. @FXML
  49. private void btnTwo(ActionEvent event) {
  50. texto.setText("2");
  51. }
  52.  
  53. @FXML
  54. private void btnThree(ActionEvent event) {
  55. texto.setText("3");
  56. }
  57.  
  58. @FXML
  59. private void btnFour(ActionEvent event) {
  60. texto.setText("4");
  61. }
  62.  
  63. @FXML
  64. private void btnFive(ActionEvent event) {
  65. texto.setText("5");
  66. }
  67.  
  68. @FXML
  69. private void btnSix(ActionEvent event) {
  70. texto.setText("6");
  71. }
  72.  
  73. @FXML
  74. private void btnSevent(ActionEvent event) {
  75. texto.setText("7");
  76. }
  77.  
  78. @FXML
  79. private void btnEight(ActionEvent event) {
  80. texto.setText("8");
  81. }
  82.  
  83. @FXML
  84. private void btnNine(ActionEvent event) {
  85. texto.setText("9");
  86. }
  87.  
  88. @FXML
  89. private void btnZero(ActionEvent event) {
  90. texto.setText("0");
  91. }
  92.  
  93. @FXML
  94. private void btnPoint(ActionEvent event) {
  95. texto.setText(".");
  96. }
  97.  
  98. @FXML
  99. private void btnPlus(ActionEvent event) {
  100. texto.setText("+");
  101. }
  102.  
  103. @FXML
  104. private void btnMinus(ActionEvent event) {
  105. texto.setText("-");
  106. }
  107.  
  108. @FXML
  109. private void btnBy(ActionEvent event) {
  110. texto.setText("*");
  111. }
  112.  
  113. @FXML
  114. private void btnDivided(ActionEvent event) {
  115. texto.setText("/");
  116. }
  117.  
  118. @FXML
  119. private void btnErrase(ActionEvent event){
  120. texto.deletePreviousChar();
  121. }
  122.  
  123. @FXML
  124. private void btnTotal(ActionEvent event){
  125. texto.getText();
  126. }
  127.  
  128. @Override
  129. public void initialize(URL url, ResourceBundle rb) {
  130. // TODO
  131. }
  132.  
  133. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement