Advertisement
Guest User

Untitled

a guest
Jan 8th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.23 KB | None | 0 0
  1. /*
  2.  * Copyright (c) 2012, 2014 Oracle and/or its affiliates.
  3.  * All rights reserved. Use is subject to license terms.
  4.  *
  5.  * This file is available and licensed under the following license:
  6.  *
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted provided that the following conditions
  9.  * are met:
  10.  *
  11.  *  - Redistributions of source code must retain the above copyright
  12.  *    notice, this list of conditions and the following disclaimer.
  13.  *  - Redistributions in binary form must reproduce the above copyright
  14.  *    notice, this list of conditions and the following disclaimer in
  15.  *    the documentation and/or other materials provided with the distribution.
  16.  *  - Neither the name of Oracle nor the names of its
  17.  *    contributors may be used to endorse or promote products derived
  18.  *    from this software without specific prior written permission.
  19.  *
  20.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21.  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22.  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  23.  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  24.  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  25.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  26.  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27.  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28.  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30.  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31.  */
  32. package sample;
  33.  
  34. import javafx.application.Application;
  35. import javafx.event.ActionEvent;
  36. import javafx.event.EventHandler;
  37. import javafx.geometry.Insets;
  38. import javafx.geometry.Pos;
  39. import javafx.scene.Scene;
  40. import javafx.scene.control.Button;
  41. import javafx.scene.control.Label;
  42. import javafx.scene.control.PasswordField;
  43. import javafx.scene.control.TextField;
  44. import javafx.scene.layout.GridPane;
  45. import javafx.scene.layout.HBox;
  46. import javafx.scene.paint.Color;
  47. import javafx.scene.text.Font;
  48. import javafx.scene.text.FontWeight;
  49. import javafx.scene.text.Text;
  50. import javafx.stage.Stage;
  51.  
  52. import static javafx.geometry.HPos.RIGHT;
  53.  
  54. public class Main extends Application {
  55.  
  56.     @Override
  57.     public void start(Stage primaryStage) {
  58.         primaryStage.setTitle("JavaFX Welcome");
  59.         GridPane grid = new GridPane();
  60.         grid.setAlignment(Pos.CENTER);
  61.         grid.setHgap(10);
  62.         grid.setVgap(10);
  63.         grid.setPadding(new Insets(25, 25, 25, 25));
  64.  
  65.         Text scenetitle = new Text("Welcome");
  66.         scenetitle.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20));
  67.         grid.add(scenetitle, 0, 0, 2, 1);
  68.  
  69.         Label userName = new Label("User Name:");
  70.         grid.add(userName, 0, 1);
  71.  
  72.         TextField userTextField = new TextField();
  73.         grid.add(userTextField, 1, 1);
  74.  
  75.         Label email=new Label("Email:");
  76.         grid.add(email,0,2);
  77.  
  78.         TextField emailTextField=new TextField();
  79.         grid.add(emailTextField,1,2);
  80.  
  81.         Label pw = new Label("Password:");
  82.         grid.add(pw, 0, 3);
  83.  
  84.         PasswordField pwBox = new PasswordField();
  85.         grid.add(pwBox, 1, 3);
  86.  
  87.  
  88.  
  89.         Button btn = new Button("Sign in");
  90.         HBox hbBtn = new HBox(10);
  91.         hbBtn.setAlignment(Pos.BOTTOM_RIGHT);
  92.         hbBtn.getChildren().add(btn);
  93.         grid.add(hbBtn, 1, 4);
  94.  
  95.         final Text actiontarget = new Text();
  96.         grid.add(actiontarget, 0, 6);
  97.         grid.setColumnSpan(actiontarget, 2);
  98.         grid.setHalignment(actiontarget, RIGHT);
  99.         actiontarget.setId("actiontarget");
  100.  
  101.         btn.setOnAction(new EventHandler<ActionEvent>() {
  102.  
  103.             @Override
  104.             public void handle(ActionEvent e) {
  105.                 actiontarget.setFill(Color.FIREBRICK);
  106.                 actiontarget.setText(emailTextField.toString());
  107.             }
  108.         });
  109.  
  110.         Scene scene = new Scene(grid, 350, 275);
  111.         primaryStage.setScene(scene);
  112.         primaryStage.show();
  113.     }
  114.  
  115.     public static void main(String[] args) {
  116.         launch(args);
  117.     }
  118.  
  119. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement