JavaFX Tutorial 06 Create Button Java GUI
Code Source :
@Override
public void start(Stage primaryStage) {
// cretae Group
Group gr = new Group();
Button btn = new Button("Login");
btn.setPrefSize(320, 80);
btn.setTextFill(Color.RED);
btn.setBackground(new Background(new BackgroundFill(Color.GREEN, CornerRadii.EMPTY, Insets.EMPTY)));
btn.setBorder(new Border(new BorderStroke(Color.RED, BorderStrokeStyle.DASHED, CornerRadii.EMPTY, BorderWidths.DEFAULT)));
gr.getChildren().add(btn);
// create scene
Scene sc = new Scene(gr);
primaryStage.setScene(sc);
// Title Stage
primaryStage.setTitle("Tutorial Textfield");
primaryStage.setWidth(450);
primaryStage.setHeight(300);
primaryStage.show();
}
*************** Libraries Importing ******************
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Cursor;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.control.Tooltip;
import javafx.scene.image.ImageView;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;
import javafx.scene.layout.Border;
import javafx.scene.layout.BorderStroke;
import javafx.scene.layout.BorderStrokeStyle;
import javafx.scene.layout.BorderWidths;
import javafx.scene.layout.CornerRadii;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.stage.Stage;
A JavaFX Button control enables a JavaFX application to have some action executed when the application user clicks the button. The JavaFX Button control is represented by the class javafx.scene.control.Button . A JavaFX Button can have a text and an icon on it which indicate to the user what clicking the button will do.
On this page of the site you can watch the video online JavaFX Tutorial 06 - Create Button JavaFX (Java GUI) with a duration of hours minute second in good quality, which was uploaded by the user Code Amir 01 January 1970, share the link with friends and acquaintances, this video has already been watched 2,005 times on youtube and it was liked by 16 viewers. Enjoy your viewing!