Advertisement
Guest User

Untitled

a guest
Dec 12th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.24 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package paraugs;
  7. import javafx.application.Application;
  8. import javafx.scene.Scene;
  9. import javafx.scene.control.Button;
  10. import javafx.scene.control.Label;
  11. import javafx.scene.control.TextField;
  12. import javafx.stage.Stage;
  13.  
  14. import java.util.Arrays;
  15. import javafx.geometry.Insets;
  16. import javafx.scene.control.Alert;
  17. import javafx.scene.control.PasswordField;
  18. import javafx.scene.control.ScrollPane;
  19. import javafx.scene.control.TextArea;
  20. import javafx.scene.layout.GridPane;
  21. import javafx.scene.paint.Color;
  22. /**
  23.  *
  24.  * @author anrij
  25.  */
  26. public class Paraugs extends Application {
  27.  
  28.     /**
  29.      * @param args the command line arguments
  30.      */
  31.     public static void main(String[] args) {
  32.         launch(args);
  33.     }
  34.     @Override
  35.     public void start(Stage primaryStage) {
  36.         Label lbl = new Label();
  37.         TextField TX = new TextField();
  38.         Alert alert = new Alert(Alert.AlertType.ERROR);
  39.         PasswordField pw = new PasswordField();
  40.         Button btn = new Button();
  41.        
  42.         alert.getDialogPane().setExpandableContent(new ScrollPane(new TextArea("kaka")));
  43.        
  44.         btn.setText("Login");
  45.        
  46.         TX.setPrefWidth(200);
  47.        
  48.         GridPane box = new GridPane();
  49.         box.setPadding(new Insets(10, 10, 10, 10));
  50.         box.setVgap(5);
  51.         box.setHgap(5);
  52.         GridPane.setConstraints(TX, 0, 1);
  53.         GridPane.setConstraints(lbl, 0, 4);
  54.         GridPane.setConstraints(btn, 0, 3);
  55.         GridPane.setConstraints(pw, 0, 2);
  56.         box.getChildren().addAll(Arrays.asList(lbl, btn, TX, pw));
  57.  
  58.         btn.setOnAction(e -> {
  59.             if(TX.getText().equals("misters_x") && pw.getText().equals("parole")) {
  60.                 alert.showAndWait();
  61.             } else {
  62.                 lbl.setText("Lietotājvārds vai parole nav pareiza!");
  63.                 lbl.setTextFill(Color.rgb(210, 39, 30));
  64.             }
  65.         });
  66.        
  67.         primaryStage.setTitle("Paraugs");
  68.         primaryStage.setScene(new Scene(box, 210, 140));
  69.         primaryStage.show();
  70.        
  71.     }
  72.    
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement