In this example, I will just put a picture and code up. The code is fairly self explainatory, and I am lazy.

ui01

package fxSceneGraph;
import javax.swing.JOptionPane;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.PasswordField;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.stage.Stage;


public class Login extends Application{
public static void main(String args[]) {
launch(args);
}

@Override
public void start(Stage s) throws Exception {
s.setTitle("This is a new JavaFX application!");
s.setResizable(false);

Button login = new Button();
Label logLabel1 = new Label("Password:");
PasswordField logField1 = new PasswordField ();

Label logLabel2 = new Label("Username:");
TextField logField2 = new TextField ();

login.setText("Login");
login.getStyleClass().add("green-button");

login.setOnAction(new EventHandler<ActionEvent>() {

@Override
public void handle(ActionEvent event) {
JOptionPane.showMessageDialog(null, "Login successful");

}

});
login.setLayoutX(170);
login.setLayoutY(200);
login.setMinWidth(100);
login.setMinHeight(50);

logField1.setLayoutX(150);
logField1.setLayoutY(150);
logField1.setMinWidth(100);
logField1.setMinHeight(20);

logLabel1.setLayoutX(51);
logLabel1.setLayoutY(150);
logLabel1.setMinWidth(100);
logLabel1.setMinHeight(20);
logLabel1.setTextFill(Color.web("#80ff80"));
logLabel1.setFont(new Font("Arial", 20));

logField2.setLayoutX(150);
logField2.setLayoutY(100);
logField2.setMinWidth(100);
logField2.setMinHeight(20);

logLabel2.setLayoutX(51);
logLabel2.setLayoutY(100);
logLabel2.setMinWidth(100);
logLabel2.setMinHeight(20);
logLabel2.setTextFill(Color.web("#80ff80"));
logLabel2.setFont(new Font("Arial", 20));

Pane pane = new Pane();
pane.getStyleClass().add("background");
pane.getChildren().addAll(login, logField1, logLabel1, logField2, logLabel2);
//pane.getChildren().addAll(textField1, label1);
Scene scene = new Scene(pane, 400,400);
scene.getStylesheets().add("style.css");
s.setScene(scene);
s.show();
}
}</pre>
<pre>
Advertisements