In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the knowledge of "how to achieve a simple login interface for Java". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Effect.
Code import javafx.application.Application;import javafx.event.ActionEvent;import javafx.event.EventHandler;import javafx.geometry.Insets;import javafx.geometry.Pos;import javafx.scene.Scene;import javafx.scene.control.Button;import javafx.scene.control.Label;import javafx.scene.control.TextField;import javafx.scene.layout.GridPane;import javafx.scene.layout.HBox;import javafx.scene.text.Text;import javafx.stage.Stage;import static javafx.geometry.HPos.RIGHT Public class Login1 extends Application {@ Overridepublic void start (Stage primaryStage) {primaryStage.setTitle ("JavaFX Welcome"); / / allows developers to create a flexible grid to lay out their content nodes by row. GridPane grid = new GridPane (); / / display gridlines / / grid.setGridLinesVisible (true); / / Center grid.setAlignment (Pos.CENTER); / / spacing between rows and rows grid.setHgap (10); grid.setVgap (10); / / spacing grid.setPadding around the edge of the panel (new Insets (25,25,25)) Text scenetitle = new Text ("Welcome"); / / scenetitle.setFont (Font.font ("Tahoma", FontWeight.NORMAL, 20)); grid.add (scenetitle, 0,0,2,1); Label userName = new Label ("User Name:"); grid.add (userName, 0,1); TextField name = new TextField () Name.setPromptText ("Enter your name."); grid.add (name, 1,1); Label pw = new Label ("Password:"); grid.add (pw, 0,2); TextField passwordField = new TextField (); name.setPromptText ("Enter your password.") Grid.add (passwordField, 1,2); 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, 0,6); GridPane.setColumnSpan (actiontarget, 2); GridPane.setHalignment (actiontarget, RIGHT); btn.setOnAction (new EventHandler () {@ Overridepublic void handle (ActionEvent e) {/ / actiontarget.setFill (Color.FIREBRICK)) Actiontarget.setText ("Sign in button pressed");}}) / * scene is created and uses gripane as the root node, which is a common usage layout when building an interface using the layout container, which can automatically resize * / Scene scene = new Scene (grid, 300,275); primaryStage.setScene (scene); primaryStage.show () } public static void main (String [] args) {launch (args);}} "how to implement a simple login interface for Java" ends here. Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.