Monty374

JFX 7.4

Dec 7th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. package divisible.by.pkg3;
  2.  
  3. import javafx.scene.control.*;
  4. import javafx.application.Application;
  5. import javafx.geometry.HPos;
  6. import javafx.geometry.Insets;
  7. import javafx.geometry.Pos;
  8. import javafx.scene.Scene;
  9. import javafx.scene.layout.GridPane;
  10. import javafx.stage.Stage;
  11.  
  12. /**
  13. *
  14. * @author Monty
  15. */
  16. public class DivisibleBy3 extends Application {
  17. private TextField tfNum = new TextField();
  18. private TextField tfOut = new TextField();
  19. private Label lblOut = new Label();
  20. private Button btCheck = new Button("Check");
  21. private String end;
  22.  
  23. @Override
  24. public void start(Stage stage1) {
  25. GridPane gp = new GridPane();
  26. gp.setHgap(5);
  27. gp.setVgap(5);
  28. gp.add(new Label("Enter int:"),0,0);
  29. gp.add(tfNum,1,0);
  30. gp.add(btCheck,0,1);
  31. gp.add(lblOut,1,1);
  32.  
  33. btCheck.setOnAction(e -> checkInt());
  34.  
  35.  
  36.  
  37. Scene scene = new Scene(gp, 300,100);
  38. stage1.setTitle("Divisible By 3");
  39. stage1.setScene(scene);
  40. stage1.show();
  41. }
  42.  
  43. private void checkInt(){
  44. int num = Integer.parseInt(tfNum.getText());
  45. if(num%3 == 0){
  46. end = "Number is divisible by 3.";
  47.  
  48. } else {
  49. end = "Number is not divisible by 3.";
  50. // gp.add(new Label(end),1,1);
  51. }
  52.  
  53. lblOut.setText(end);
  54. }
  55.  
  56. public static void main(String[] args) {
  57. launch(args);
  58. }
  59.  
  60. }
Advertisement
Add Comment
Please, Sign In to add comment