62,628
社区成员
发帖
与我相关
我的任务
分享

package minesweeper;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Dialog;
import javafx.scene.control.Label;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextField;
import javafx.scene.control.ButtonBar.ButtonData;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage primaryStage) {
GridPane grid = new GridPane();
grid.setAlignment(Pos.CENTER);
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(25, 25, 25, 25));
Button button = new Button("2019网络技术云计算1班");
button.setOnMouseClicked((evt)->{
ButtonType loginButtonType = new ButtonType("OK", ButtonData.OK_DONE);
Dialog<String> dialog = new Dialog<>();
dialog.setTitle("哈哈!");
dialog.setContentText("你上当了!");
dialog.getDialogPane().getButtonTypes().add(loginButtonType);
boolean disabled = false; // computed based on content of text fields, for example
dialog.getDialogPane().lookupButton(loginButtonType).setDisable(disabled);
dialog.showAndWait();
});
grid.add(button, 0, 0);
Scene scene = new Scene(grid, 300, 275);
primaryStage.setScene(scene);
primaryStage.show();
}
/**
* The main() method is ignored in correctly deployed JavaFX application. main()
* serves only as fallback in case the application can not be launched through
* deployment artifacts, e.g., in IDEs with limited FX support. NetBeans ignores
* main().
*
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
}