Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main extends Application {
- private Boolean buttonPressed = false;
- public static void main(String[] args) {
- launch(args);
- }
- @Override
- public void start(Stage stage) throws Exception {
- BorderPane appWindow = new BorderPane();
- appWindow.setStyle("-fx-alignment: center; -fx-padding: 30 0 0 30");
- appWindow.setBackground(new Background(new BackgroundFill(Color.PERU, null, null)));
- GridPane loginContainer = new GridPane();
- appWindow.setCenter(loginContainer);
- TextField username = new TextField();
- PasswordField password = new PasswordField();
- Label userNameDesc = new Label("Username");
- Label passwordDesc = new Label("Password");
- Button logInBtn = new Button("Log In");
- logInBtn.setTranslateX(100);
- logInBtn.setTranslateY(20);
- logInBtn.setOnAction(event -> {
- if (!buttonPressed) {
- appWindow.getCenter().setOpacity(30);
- buttonPressed = true;
- System.out.println("Opacity set to " + appWindow.getCenter().getOpacity());
- }
- else {
- appWindow.getCenter().setOpacity(100);
- buttonPressed = false;
- System.out.println("Opacity set to " + appWindow.getCenter().getOpacity());
- }
- });
- loginContainer.addColumn(0, userNameDesc, passwordDesc);
- loginContainer.addColumn(1, username, password);
- loginContainer.add(logInBtn, 1, 2);
- Scene scene = new Scene(appWindow, 300, 250);
- stage.setScene(scene);
- stage.show();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement