Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javafx.application.Application;
- import javafx.event.ActionEvent;
- import javafx.event.EventHandler;
- import javafx.scene.Scene;
- import javafx.scene.control.Button;
- import javafx.scene.layout.StackPane;
- import javafx.stage.Stage;
- import javafx.scene.layout.*;
- import javafx.geometry. *;
- import javafx.scene.control. *;
- import javafx.scene.text.*;
- import javafx.scene.paint.*;
- public class JavaFXForm extends Application{
- public static void main(String[] args) {
- launch(args);
- }
- @Override
- public void start(Stage primaryStage){
- primaryStage.setTitle("JavaFX Welcome");
- primaryStage.show();
- GridPane grid = new GridPane();
- grid.setAlignment(Pos.CENTER);
- grid.setHgap(10);
- grid.setVgap(10);
- grid.setPadding(new Insets (25, 25, 25, 25));
- Scene scene = new Scene(grid, 300, 275);
- primaryStage.setScene(scene);
- Text scenetitle = new Text("Welcome");
- scenetitle.setFont(Font.font("tahoma", FontWeight.NORMAL, 20));
- grid.add(scenetitle, 0, 0, 2, 1);
- Label userName = new Label("UserName: ");
- grid.add(userName, 0, 1);
- TextField userTextField = new TextField ();
- grid.add(userTextField, 1, 1);
- Label pw = new Label ("Password: ");
- grid.add(pw, 0, 2);
- PasswordField pwBox = new PasswordField();
- grid.add(pwBox, 1, 2);
- //grid.setGridLinesVisible(true);
- Button btn = new Button ("Sign in");
- HBox hbBtn = new HBox(10);
- hbBtn.setAlignment(Pos.BOTTOM_RIGHT);
- hbBtn.getChildren().add(btn);
- grid.add(hbBtn, 1, 4);
- final Text actiontarget = new Text();
- grid.add (actiontarget, 1, 6);
- btn.setOnAction(new EventHandler<ActionEvent>() {
- @Override
- public void handle (ActionEvent e) {
- actiontarget.setFill(Color.FIREBRICK);
- actiontarget.setText("Sign in button pressed");
- }
- });
- System.out.println("Hello");
- System.out.println(userTextField.getText());
- System.out.println(pwBox.getText());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement