Advertisement
Guest User

Untitled

a guest
Jan 25th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. public class Main extends Application {
  2.  
  3.  
  4. private Boolean buttonPressed = false;
  5.  
  6.  
  7. public static void main(String[] args) {
  8. launch(args);
  9. }
  10.  
  11. @Override
  12. public void start(Stage stage) throws Exception {
  13.  
  14. BorderPane appWindow = new BorderPane();
  15. appWindow.setStyle("-fx-alignment: center; -fx-padding: 30 0 0 30");
  16. appWindow.setBackground(new Background(new BackgroundFill(Color.PERU, null, null)));
  17. GridPane loginContainer = new GridPane();
  18. appWindow.setCenter(loginContainer);
  19.  
  20. TextField username = new TextField();
  21. PasswordField password = new PasswordField();
  22. Label userNameDesc = new Label("Username");
  23. Label passwordDesc = new Label("Password");
  24. Button logInBtn = new Button("Log In");
  25.  
  26. logInBtn.setTranslateX(100);
  27. logInBtn.setTranslateY(20);
  28.  
  29. logInBtn.setOnAction(event -> {
  30.  
  31. if (!buttonPressed) {
  32. appWindow.getCenter().setOpacity(30);
  33. buttonPressed = true;
  34. System.out.println("Opacity set to " + appWindow.getCenter().getOpacity());
  35. }
  36.  
  37. else {
  38. appWindow.getCenter().setOpacity(100);
  39. buttonPressed = false;
  40. System.out.println("Opacity set to " + appWindow.getCenter().getOpacity());
  41. }
  42.  
  43. });
  44.  
  45. loginContainer.addColumn(0, userNameDesc, passwordDesc);
  46. loginContainer.addColumn(1, username, password);
  47. loginContainer.add(logInBtn, 1, 2);
  48.  
  49. Scene scene = new Scene(appWindow, 300, 250);
  50. stage.setScene(scene);
  51. stage.show();
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement